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);
        }