Ejemplo n.º 1
0
        private void btnManagerAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbManagers.Items.Count > 0)
                {
                    DivisionManage obj = new DivisionManage();
                    obj.ManagerID  = cmbManagers.SelectedValue.ToString();
                    obj.DivisionID = Convert.ToInt64(txtID.Text);

                    int res = objDivisionManageDL.Add(obj, objSelectedManager);
                    if (res > 0)
                    {
                        bindManagers.DataSource   = objDivisionManageDL.Get(obj.DivisionID);
                        objSelectedManager        = new DivisionManage();
                        cmbManagers.SelectedIndex = -1;
                    }
                }
            }
            catch (SqlException ex)
            {
                if (ex.Number == 2627)
                {
                    MessageBox.Show(this, "Manager already added", "Duplicate Record", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while saving Manager", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
 private void ClearForm()
 {
     txtID.Text            = "[Auto]";
     txtName.Text          = "";
     cmbType.SelectedIndex = 0;
     IsSelect = false;
     btnManagerAdd.Enabled   = false;
     btnMangerDelete.Enabled = false;
     btnManagerClear.Enabled = false;
     objSelectedManager      = new DivisionManage();
     bindManagers.DataSource = objDivisionManageDL.Get(0);
 }
Ejemplo n.º 3
0
        public int Delete(DivisionManage obj)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@Original_DivisionID", obj.DivisionID),
                    new SqlParameter("@Original_ManagerID", obj.ManagerID)
                };


                return(Execute.RunSP_RowsEffected(Connection, "SPDELETE_DivisionManage", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Ejemplo n.º 4
0
        public int Add(DivisionManage obj, DivisionManage OriginalObj)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@DivisionID", obj.DivisionID),
                    new SqlParameter("@ManagerID", obj.ManagerID),
                    new SqlParameter("@Original_DivisionID", OriginalObj.DivisionID),
                    new SqlParameter("@Original_ManagerID", OriginalObj.ManagerID)
                };


                return(Execute.RunSP_RowsEffected(Connection, "SPADD_DivisionManage_Update", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Ejemplo n.º 5
0
 private void btnMangerDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (objSelectedManager.DivisionID > 0)
         {
             DialogResult dr = MessageBox.Show(this, "Are you sure you want to delete Selected manager?\n\nClick Yes to Delete", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
             if (dr == DialogResult.Yes)
             {
                 int res = objDivisionManageDL.Delete(objSelectedManager);
                 bindManagers.DataSource = objDivisionManageDL.Get(Convert.ToInt64(txtID.Text));
                 objSelectedManager      = new DivisionManage();
             }
         }
         else
         {
             MessageBox.Show(this, "Please select a Manager", "Selection Empty", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception)
     {
         MessageBox.Show(this, "Error occured while deleting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 6
0
 private void btnManagerClear_Click(object sender, EventArgs e)
 {
     cmbManagers.SelectedIndex = -1;
     objSelectedManager        = new DivisionManage();
 }