private void btnUpdate_Click(object sender, EventArgs e) { newbasicpay = Convert.ToDecimal(txtBasicPay.Text); if (emp.basic_pay != newbasicpay) { BasicPay bp = new BasicPay(); bp.empid = emp.empid; bp.basic_pay = newbasicpay; if (bp.save()) { this.Dispose(); } else { MessageBox.Show("There was a problem updating employee's basic pay : \n" + db.err.Message); } } }
public Boolean save() { MySqlCommand cmd = new MySqlCommand(); cmd.Connection = db.con; cmd.CommandText = "EMP_INSERT"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("_empid", Convert.ToInt32(empid).ToString("0000")); cmd.Parameters.AddWithValue("_fname", fname); cmd.Parameters.AddWithValue("_lname", lname); cmd.Parameters.AddWithValue("_mname", mname); cmd.Parameters.AddWithValue("_birthday", birthdate); cmd.Parameters.AddWithValue("_contactno", contactno); cmd.Parameters.AddWithValue("_gender", gender); cmd.Parameters.AddWithValue("_address", address); cmd.Parameters.AddWithValue("_emp_status", emp_status); cmd.Parameters.AddWithValue("_imagearr", pic); int length = (pic != null) ? pic.Length : 0; cmd.Parameters.AddWithValue("_imagesize", length); cmd.Parameters.AddWithValue("_emp_position", position); cmd.Parameters.AddWithValue("_branchid", branch); cmd.Parameters.AddWithValue("_tinno", tinno); //encrypt password using (MD5 md5Hash = MD5.Create()) { string hash = Global.GetMd5Hash(md5Hash, password); cmd.Parameters.AddWithValue("_pword", hash); } try { //db.con.Open(); cmd.ExecuteNonQuery(); BasicPay p = new BasicPay(); p.empid = Convert.ToInt32(this.empid).ToString("0000"); p.basic_pay = this.basic_pay; p.date_updated = DateTime.Now; if (p.save()) { return(true); } else { return(false); } } catch (Exception e) { db.err = null; db.err = e; Logger.WriteErrorLog("ERROR : EMPLOYEE SAVE MODULE :" + e.Message); return(false); } }//end save
public Boolean save() { MySqlCommand cmd = new MySqlCommand(); cmd.Connection = db.con; cmd.CommandText = "EMP_INSERT"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("_empid", Convert.ToInt32(empid).ToString("0000")); cmd.Parameters.AddWithValue("_fname", fname); cmd.Parameters.AddWithValue("_lname", lname); cmd.Parameters.AddWithValue("_mname", mname); cmd.Parameters.AddWithValue("_birthday", birthdate); cmd.Parameters.AddWithValue("_contactno", contactno); cmd.Parameters.AddWithValue("_gender", gender); cmd.Parameters.AddWithValue("_address", address); cmd.Parameters.AddWithValue("_emp_status", emp_status); cmd.Parameters.AddWithValue("_imagearr", pic); int length = (pic != null) ? pic.Length : 0; cmd.Parameters.AddWithValue("_imagesize", length); cmd.Parameters.AddWithValue("_emp_position", position); cmd.Parameters.AddWithValue("_branchid", branch); cmd.Parameters.AddWithValue("_tinno", tinno); //encrypt password using (MD5 md5Hash = MD5.Create()) { string hash = Global.GetMd5Hash(md5Hash, password); cmd.Parameters.AddWithValue("_pword", hash); } try { //db.con.Open(); cmd.ExecuteNonQuery(); BasicPay p = new BasicPay(); p.empid = Convert.ToInt32(this.empid).ToString("0000"); p.basic_pay = this.basic_pay; p.date_updated = DateTime.Now; if (p.save()){ return true; } else { return false; } } catch (Exception e) { db.err = null; db.err = e; Logger.WriteErrorLog("ERROR : EMPLOYEE SAVE MODULE :" + e.Message); return false; } }