Beispiel #1
0
        private void dgvBillCode7LayerList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == 6)
                {
                    //DeleteForBillCode7Layer
                    if (!CheckingRoleManagementFeature("BillCodeLayerEditOrDelete"))
                    {
                        MessageBox.Show("Access Deined for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    DialogResult result = MessageBox.Show(this, "Are you sure you want to delete?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result.Equals(DialogResult.OK))
                    {
                        DataGridViewRow row = dgvBillCode7LayerList.Rows[e.RowIndex];
                        billCode7LayerID = Convert.ToString(row.Cells[0].Value);
                        BillCode7Layer billCodeObj = (BillCode7Layer)row.DataBoundItem;
                        billCodeObj = (from b in mbsEntities.BillCode7Layer where b.BillCode7LayerID == billCodeObj.BillCode7LayerID select b).FirstOrDefault();
                        var customerCount = (from c in billCodeObj.Customers where c.Active == true select c).Count();
                        if (customerCount > 0)
                        {
                            MessageBox.Show("This Bill Code is used in Customer !", "Cannot Delete", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        dgvBillCode7LayerList.DataSource = "";
                        BillCode7Layer billCode7Layer = (from b in mbsEntities.BillCode7Layer where b.BillCode7LayerID == billCode7LayerID select b).FirstOrDefault();
                        billCode7Layer.Active        = false;
                        billCode7Layer.DeletedUserID = UserID;
                        billCode7Layer.DeletedDate   = DateTime.Now;
                        billCode7LayerController.DeleteBillCode7Layer(billCode7Layer);
                        dgvBillCode7LayerList.DataSource = (from b in mbsEntities.BillCode7Layer where b.Active == true orderby b.BillCode7LayerNo descending select b).ToList();
                        MessageBox.Show(this, "Successfully Deleted!", "Delete Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        FormRefresh();
                    }
                }
                else if (e.ColumnIndex == 5)
                {
                    //EditBillCode7Layer
                    if (!CheckingRoleManagementFeature("BillCodeLayerEditOrDelete"))
                    {
                        MessageBox.Show("Access Deined for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    string            _billCode7LayerID;
                    BillCode7Layerfrm billcode7LayerForm = new BillCode7Layerfrm();
                    billcode7LayerForm.isEdit                   = true;
                    billcode7LayerForm.Text                     = "Edit BillCode";
                    _billCode7LayerID                           = Convert.ToString(dgvBillCode7LayerList.Rows[e.RowIndex].Cells[0].Value);
                    billcode7LayerForm.billCode7LayerID         = _billCode7LayerID;
                    billcode7LayerForm.billCode7LayerDetailList = mbsEntities.BillCode7LayerDetail.Where(x => x.BillCode7LayerID == _billCode7LayerID && x.BillCode7Layer.Active == true && x.Active == true).OrderBy(y => y.LowerLimit).ToList();
                    billcode7LayerForm.UserID                   = UserID;
                    billcode7LayerForm.ShowDialog();
                    this.Close();
                }
            }
        }
Beispiel #2
0
        private void btnAddNewBillCode_Click(object sender, EventArgs e)
        {
            if (!CheckingRoleManagementFeature("BillCodeLayerAdd"))
            {
                MessageBox.Show("Access Deined for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            BillCode7Layerfrm billcode7LayerForm = new BillCode7Layerfrm();

            billcode7LayerForm.UserID = UserID;
            billcode7LayerForm.Show();
            this.Close();
        }