Ejemplo n.º 1
0
        private bool InsertEmployess()
        {
            try
            {
                using (var tran = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required,
                                                                           new System.Transactions.TransactionOptions {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
                }))
                {
                    DataTable dtCheckInsert;

                    byte[] image = _unityClass.CoverFilltoByte(imgChonAnh.ImageLocation);
                    if (rdoNam.Checked == true)
                    {
                        dtCheckInsert = _nhanvienModel.InsertEmployess(txtMaNV.Text, txtTenNV.Text, rdoNam.Text, txtDiaChi.Text, txtUser.Text, txtPass.Text, txtSDT.Text, image, lkuChucVu.EditValue.ToString());
                    }
                    else
                    {
                        dtCheckInsert = _nhanvienModel.InsertEmployess(txtMaNV.Text, txtTenNV.Text, rdoNu.Text, txtDiaChi.Text, txtUser.Text, txtPass.Text, txtSDT.Text, image, lkuChucVu.EditValue.ToString());
                    }
                    if (dtCheckInsert.Rows.Count <= 0 || dtCheckInsert == null)
                    {
                        return(false);
                    }
                    DataTable dtCheckUpdate;
                    dtCheckUpdate = _nhanvienModel.UpdateNhomND(txtUser.Text, lkuChucVu.EditValue.ToString());
                    if (dtCheckUpdate.Rows.Count <= 0 || dtCheckUpdate == null)
                    {
                        return(false);
                    }
                    tran.Complete();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, Commons.Notify, MessageBoxButtons.OK);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// btnLuu_Click -- thực hiện chức năng lưu nhân viên
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(imgChonAnh.ImageLocation))
            {
                XtraMessageBox.Show(Commons.ChooseImage, Commons.Notify, MessageBoxButtons.OK);
                return;
            }
            else if (string.IsNullOrEmpty(txtUser.Text))
            {
                XtraMessageBox.Show(Commons.WriteUset, Commons.Notify, MessageBoxButtons.OK);
                return;
            }
            else if (string.IsNullOrEmpty(txtPass.Text))
            {
                XtraMessageBox.Show(Commons.WritePass, Commons.Notify, MessageBoxButtons.OK);
                return;
            }
            DataTable dtCheckInsert;

            byte[] image = _unityClass.CoverFilltoByte(imgChonAnh.ImageLocation);
            if (rdoNam.Checked == true)
            {
                dtCheckInsert = _nhanvienModel.InsertEmployess(txtMaNV.Text, txtTenNV.Text, rdoNam.Text, txtDiaChi.Text, txtUser.Text, txtPass.Text, txtSDT.Text, image, lkuChucVu.EditValue.ToString());
            }
            else
            {
                dtCheckInsert = _nhanvienModel.InsertEmployess(txtMaNV.Text, txtTenNV.Text, rdoNu.Text, txtDiaChi.Text, txtUser.Text, txtPass.Text, txtSDT.Text, image, lkuChucVu.EditValue.ToString());
            }
            if (dtCheckInsert.Rows.Count > 0 && dtCheckInsert != null)
            {
                XtraMessageBox.Show(Commons.InsertFinish, Commons.Notify, MessageBoxButtons.OK);
                txtMaNV.Text = EmployessCde();
                LoadGridEmployess();
                return;
            }
            XtraMessageBox.Show(Commons.InsertError, Commons.Notify, MessageBoxButtons.OK);
        }