コード例 #1
0
ファイル: CustomerGroup.cs プロジェクト: suhasrake/CSLERP
 private void listCustomerGroup(int lvl)
 {
     try
     {
         grdList.Rows.Clear();
         CustomerGroupDB      cgdb   = new CustomerGroupDB();
         List <customergroup> cgroup = cgdb.getCustomerGroupDetails(lvl);
         int i = 1;
         foreach (customergroup cg in cgroup)
         {
             grdList.Rows.Add();
             grdList.Rows[grdList.RowCount - 1].Cells["LineNo"].Value           = i;
             grdList.Rows[grdList.RowCount - 1].Cells["GroupCode"].Value        = cg.GroupCode;
             grdList.Rows[grdList.RowCount - 1].Cells["GroupDescription"].Value = cg.GroupDescription;
             grdList.Rows[grdList.RowCount - 1].Cells["CreateTime"].Value       = cg.CreateTime;
             grdList.Rows[grdList.RowCount - 1].Cells["Creator"].Value          = cg.CreateUser;
             i++;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in Customer Group  Listing");
     }
     try
     {
         enableBottomButtons();
         pnlList.Visible = true;
         btnNew.Visible  = false;
     }
     catch (Exception ex)
     {
     }
 }
コード例 #2
0
ファイル: CustomerGroup.cs プロジェクト: suhasrake/CSLERP
        public string getGroupCode()
        {
            string gc = "";

            CustomerGroupDB      cdb     = new CustomerGroupDB();
            List <customergroup> LCGroup = cdb.getCustomerGroupDetails(lvl);
            SortedSet <string>   set     = new SortedSet <string>();

            try
            {
                foreach (customergroup cg in LCGroup)
                {
                    set.Add(cg.GroupCode);
                }
                gc = set.Max;
            }
            catch (Exception ex)
            {
            }
            if (Convert.ToInt32(gc) == 0)
            {
                gc = "10";// group coe start with 10
            }
            return((Convert.ToInt32(gc) + 1).ToString());
        }
コード例 #3
0
ファイル: CustomerGroup.cs プロジェクト: suhasrake/CSLERP
        private void btnSave_Click(object sender, EventArgs e)
        {
            Boolean status = true;

            try
            {
                CustomerGroupDB             cgdb = new CustomerGroupDB();
                customergroup               cg   = new customergroup();
                System.Windows.Forms.Button btn  = sender as System.Windows.Forms.Button;
                string btnText = btnSave.Text;

                try
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(txtGroupCode.Text, @"^[0-9]+$"))
                    {
                        MessageBox.Show("GroupCode accepts only numeric characters");
                        return;
                    }
                    else
                    {
                        cg.GroupCode = txtGroupCode.Text;
                    }

                    if (!System.Text.RegularExpressions.Regex.IsMatch(txtGroupDescription.Text, @"^[\sa-zA-Z0-9]+$"))
                    {
                        MessageBox.Show("Group Description accepts only alphanumeric characters");
                        return;
                    }
                    else
                    {
                        cg.GroupDescription = txtGroupDescription.Text;
                    }

                    cg.GroupLevel = Convert.ToInt32(cmbSelectLevel.SelectedItem.ToString().Trim());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Validation failed");
                    return;
                }

                if (btnText.Equals("Save"))
                {
                    if (cgdb.validateCustomerGroup(cg))
                    {
                        if (cgdb.insertCustomerGroup(cg))
                        {
                            MessageBox.Show("Customer Code Added");
                            closeAllPanels();
                            listCustomerGroup(lvl);
                            pnlAddNew.Visible        = false;
                            pnlBottomButtons.Visible = true;
                        }
                        else
                        {
                            status = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Validation failed");
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to Insert Customer Group");
                    }
                }
                else if (btnText.Equals("update"))
                {
                    if (cgdb.validateCustomerGroup(cg))
                    {
                        if (cgdb.updateCustomerGroup(cg))
                        {
                            MessageBox.Show("Customer Group Added");
                            closeAllPanels();
                            listCustomerGroup(lvl);
                            pnlAddNew.Visible        = false;
                            pnlBottomButtons.Visible = true;
                        }
                        else
                        {
                            status = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Validation failed");
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to Insert Customer Group");
                    }
                }
                else
                {
                    MessageBox.Show("btnSave error.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Errorr in saving");
            }
        }