Exemple #1
0
        private void btnupdate_Click(object sender, EventArgs e)
        {
            Employee emp = new Employee();
            emp.empid = txtid.Text;
            emp.fname = txtfname.Text;
            emp.lname = txtlname.Text;
            emp.mname = txtmname.Text;
            emp.gender = cbogender.Text;
            emp.birthdate = dtBday.Value;
            emp.contactno = txtcontactno.Text;
            emp.address = txtaddress.Text;
            emp.position = cbopositions.Text;
            emp.basic_pay = Convert.ToDecimal(txtbasicpay.Text);
            emp.date_hired = dtemploymentdate.Value;
            emp.tinno = txttinno.Text;

            long filesize;
            MemoryStream mstream = new MemoryStream();
            pbEmpPic.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg);
            Byte[] arrImage = mstream.GetBuffer();
            filesize = mstream.Length;

            if (pbEmpPic.Image != null && (arrImage != emp.pic))
            {
                emp.pic = arrImage;
            }

            if (emp.update())
            {
                MessageBox.Show("Successful", "Updating...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                this.Parent.Height = 0;
                this.Parent.Controls.Clear();
                this.Dispose();
            }
            else
            {
                Logger.WriteErrorLog(db.err.ToString());
                MessageBox.Show("Error : " + db.err.ToString(), "Updating...", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }