I hope you to benefit from this codes inch Allah (Abdikarim dahir)
// id display to update form
private void txtId_TextChanged(object sender, EventArgs e)
{
try
{
if ([Link] != "")
{
[Link]();
string select = "select * from Employee where em_id=" + [Link] +
"";
SqlCommand cmd = new SqlCommand(select, con);
SqlDataReader dr = [Link]();
while ([Link]())
{
[Link] = [Link](1).ToString();
[Link] = [Link](2).ToString();
[Link] = [Link](3).ToString();
[Link] = [Link](4).ToString();
[Link] = [Link](5).ToString();
[Link] = [Link](6).ToString();
[Link] = [Link](7).ToString();
}
[Link]();
}
else
{
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
}
// update code
private void btnUpdate_Click(object sender, EventArgs e)
{
try
{
if ([Link] != "" && [Link] != "" && [Link] !=
""&&[Link] != "" && [Link] != "" && [Link] !=
""&&[Link]!="")
{
[Link]();
string update = "update employee set em_firstname='" + [Link]
+ "',em_middleName='" + [Link] + "',em_lastName='"
+ [Link] +"',em_type='"+[Link] +"',Phone=" +
[Link] +",salary="+[Link]+",em_address='" + [Link] + "'where
em_id=" + [Link] + "";
SqlCommand cmd = new SqlCommand(update, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
[Link]();
[Link]("Record Update successfully", "Message",
[Link], [Link]);
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
}
else
{
[Link]("Please Enter Employee Id or Correct", "Message",
[Link], [Link]);
[Link]();
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
}
// save code
private void btnSave_Click(object sender, EventArgs e)
{
try
{
if ([Link] != "" && [Link] != "" && [Link] != "")
{
[Link]();
string save = "insert into customer
(cus_firstname,cus_middlename,cus_lastname,phone,cus_address)values('" + [Link] +
"','" +
[Link] + "','" + [Link] + "'," + [Link] +
",'" + [Link] + "')";
SqlCommand cmd = new SqlCommand(save, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
[Link]();
[Link]("Record save successfully", "Message",
[Link], [Link]);
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
}
else
{
[Link]("Please Enter First Name , Middle Name and Phone",
"Message", [Link], [Link]);
[Link]();
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
}
// code clear
private void btnClear_Click(object sender, EventArgs e)
{
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
}
// code delete
private void btnDelete_Click(object sender, EventArgs e)
{
try
{
int de =
[Link]([Link][0].Cells[0].[Link]());
DialogResult dr = [Link]("Are sure to delete the row you
selected", "message", [Link], [Link]);
if (dr == [Link])
{
[Link]();
string select = "delete from item where item_id =" + de + "";
SqlCommand cmd = new SqlCommand(select, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
[Link]();
[Link]();
[Link]("The record deleted", "Message",
[Link], [Link]);
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
}
// code calcualtion qty
private void txtQuantity_TextChanged(object sender, EventArgs e)
{
try
{
if ([Link] != "")
{
int qty = [Link]([Link]);
double price = [Link]([Link]);
double total = price * qty;
[Link] = [Link]();
}
else
{
[Link] = "0";
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
}
// update qty
private void updateQty()
{
try
{
int id = [Link]([Link]);
int a_qty = [Link]([Link]);
int qty = [Link]([Link]);
int l_qty = a_qty - qty;
[Link]();
string update = "update stock set available=" + l_qty + "where item_id="
+ id + "";
SqlCommand cmd = new SqlCommand(update, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
[Link]();
[Link]();
selectAll();
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
}
// dicscount code
private void txtDiscount_TextChanged(object sender, EventArgs e)
{
try
{
if ([Link] != "")
{
double total = [Link]([Link]);
double discount = [Link]([Link]);
double tot = total - discount;
[Link] = [Link]();
}
else
{
[Link] = "0";
[Link]();
[Link]();
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
}
// code Receipt
private void txtReceipt_TextChanged(object sender, EventArgs e)
{
try
{
if ([Link]!="")
{
double subt = [Link]([Link]);
double rec = [Link]([Link]);
double bal = subt - rec;
[Link] = [Link]();
}
else
{
[Link] = "";
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
}
// login form code
private void btnLogin_Click(object sender, EventArgs e)
{
try
{
if ([Link])
{
string role = "admin";
[Link]();
string select = "select * from loginForm where username='" +
[Link] + "' and pass='" + [Link] + "'and userRole='"+role+"'";
SqlCommand cmd = new SqlCommand(select, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
[Link](dt);
[Link]();
if ([Link] == 1)
{
Dashboard fd = new Dashboard();
[Link]();
[Link]();
}
else
{
[Link]("Incorrect Username, Password or Role please
check", "Message", [Link], [Link]);
[Link]();
}
}
else if ([Link])
{
string role="user";
[Link]();
string select = "select * from loginForm where username='" +
[Link] + "' and pass='" + [Link] + "'and userRole='"+role+"'";
SqlCommand cmd = new SqlCommand(select, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
[Link](dt);
[Link]();
if ([Link] == 1)
{
Dashboard fd = new Dashboard();
[Link]();
[Link]();
}
else
{
[Link]("Incorrect Username, Password or Role please
check", "Message", [Link], [Link]);
[Link]();
}
}
else
{
[Link]("Please fill the blank or check your Role",
"Message", [Link], [Link]);
}
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
// searching code
private void txtSearch_TextChanged(object sender, EventArgs e)
{
try
{
[Link]();
string select = "select * from Stock where item_id like'" +
[Link] + "%'or item_name like'" + [Link] + "%'";
SqlCommand cmd = new SqlCommand(select, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
}
// button hide password code and show password code
private void btnShow_Click(object sender, EventArgs e)
{
try
{
[Link]();
[Link] = none;
[Link]();
}
catch (Exception ex)
{
[Link]([Link]);
}
}
private void btnHide_Click(object sender, EventArgs e)
{
try
{
[Link]();
[Link] = '*';
[Link]();
}
catch (Exception ex)
{
[Link]([Link]);
}
}
public char none {get; set;}
// report code
private void selectAll()
{
try
{
[Link]();
string select = "select * from orders where or_id=(select max(or_id)from
Orders)";
SqlCommand cmd = new SqlCommand(select, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
[Link](dt);
[Link]();
CR_sales cr = new CR_sales();
[Link]["orders"].SetDataSource(dt);
[Link] = cr;
}
catch (Exception ex)
{
[Link]([Link], "Message", [Link],
[Link]);
}
finally
{
[Link]();
}
}