示例#1
0
 private void listStockGroup(int lvl)
 {
     try
     {
         grdList.Rows.Clear();
         StockGroupDB3      sgdb   = new StockGroupDB3();
         List <stockgroup3> sgroup = sgdb.getStockGroupDetails(lvl);
         int i = 1;
         foreach (stockgroup3 sg in sgroup)
         {
             grdList.Rows.Add();
             grdList.Rows[grdList.RowCount - 1].Cells["LineNo"].Value           = i;
             grdList.Rows[grdList.RowCount - 1].Cells["GroupCode"].Value        = sg.GroupCode;
             grdList.Rows[grdList.RowCount - 1].Cells["GroupDescription"].Value = sg.GroupDescription;
             grdList.Rows[grdList.RowCount - 1].Cells["CreateTime"].Value       = sg.CreateTime;
             grdList.Rows[grdList.RowCount - 1].Cells["Creator"].Value          = sg.CreateUser;
             i++;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in Stock Group  Listing");
     }
     try
     {
         enableBottomButtons();
         pnlList.Visible = true;
         btnNew.Visible  = false;
     }
     catch (Exception ex)
     {
     }
 }
示例#2
0
        public string getGroupCode()
        {
            string gc = "";

            StockGroupDB3      sdb     = new StockGroupDB3();
            List <stockgroup3> LSGroup = sdb.getStockGroupDetails(lvl);
            SortedSet <string> set     = new SortedSet <string>();

            try
            {
                foreach (stockgroup3 sg in LSGroup)
                {
                    set.Add(sg.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
 private void initVariables()
 {
     try
     {
         if (getuserPrivilegeStatus() == 1)
         {
             //user is only a viewer
             listOption = 6;
         }
         StockGroupDB3.fillGroupValueCombo(cmbGroup1Select, 1);
         StockGroupDB3.fillGroupValueCombo(cmbGroup2Select, 2);
         StockGroupDB3.fillGroupValueCombo(cmbGroup3Select, 3);
         CatalogueValueDB.fillCatalogValueCombo(cmbUnit, "StockUnit");
         //fillTypeCombo(cmbGroup);
         userString = Login.userLoggedInName + Main.delimiter1 + Login.userLoggedIn + Main.delimiter1 + Main.delimiter2;
         setButtonVisibility("init");
     }
     catch (Exception)
     {
     }
 }
示例#4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Boolean status = true;

            try
            {
                StockGroupDB3 sgdb = new StockGroupDB3();
                stockgroup3   sg   = new stockgroup3();
                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("This GroupCode accepts only numeric characters");
                        return;
                    }
                    else
                    {
                        sg.GroupCode = txtGroupCode.Text;
                    }

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

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

                if (btnText.Equals("Save"))
                {
                    if (sgdb.validateStockGroup(sg))
                    {
                        if (sgdb.insertStockGroup(sg))
                        {
                            MessageBox.Show("Stock Code Added");
                            closeAllPanels();
                            listStockGroup(lvl);
                            pnlAddNew.Visible        = false;
                            pnlBottomButtons.Visible = true;
                        }
                        else
                        {
                            status = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Validation failed");
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to Insert Stock Code");
                    }
                }
                else if (btnText.Equals("update"))
                {
                    if (sgdb.validateStockGroup(sg))
                    {
                        if (sgdb.updateStockGroup(sg))
                        {
                            MessageBox.Show("Stock Code Added");
                            closeAllPanels();
                            listStockGroup(lvl);
                            pnlAddNew.Visible        = false;
                            pnlBottomButtons.Visible = true;
                        }
                        else
                        {
                            status = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Validation failed");
                    }
                    if (!status)
                    {
                        MessageBox.Show("Failed to Insert Stock Code");
                    }
                }
                else
                {
                    MessageBox.Show("btnSave error.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Errorr in saving");
            }
        }