示例#1
0
 private void listStockGroup(int lvl)
 {
     try
     {
         grdList.Rows.Clear();
         StockGroupDB      sgdb   = new StockGroupDB();
         List <stockgroup> sgroup = sgdb.getStockGroupDetails(lvl);
         int i = 1;
         foreach (stockgroup 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 = "";

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

            try
            {
                foreach (stockgroup 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 lvOK_Click1(object sender, EventArgs e)
 {
     try
     {
         //if(lv.CheckedIndices.Count == 0)
         //{
         //    MessageBox.Show("Select One Group Code");
         //    return;
         //}
         string       children = "";
         StockGroupDB sgdb     = new StockGroupDB();
         foreach (ListViewItem itemRow in lv.Items)
         {
             if (itemRow.Checked)
             {
                 children += itemRow.SubItems[1].Text + Main.delimiter1;
             }
         }
         int level = Convert.ToInt32(cmbSelectLevel.SelectedItem);
         if (sgdb.updateProductGroupMapping(children, level, grpCode))
         {
             MessageBox.Show("Product Group mapped Sucessfully");
         }
         else
         {
             MessageBox.Show("Product Group mapping Failed");
             return;
         }
         frmPopup.Close();
         frmPopup.Dispose();
     }
     catch (Exception ex)
     {
     }
 }
示例#4
0
        private void showGroupListView(string gcode)
        {
            try
            {
                frmPopup = new Form();
                frmPopup.StartPosition   = FormStartPosition.CenterScreen;
                frmPopup.BackColor       = Color.CadetBlue;
                frmPopup.MaximizeBox     = false;
                frmPopup.MinimizeBox     = false;
                frmPopup.ControlBox      = false;
                frmPopup.FormBorderStyle = FormBorderStyle.FixedSingle;

                frmPopup.Size = new Size(450, 310);
                //frmPopup.Location = new Point(579, 78);
                int   level      = Convert.ToInt32(cmbSelectLevel.SelectedItem);
                Label pnlHeading = new Label();
                pnlHeading.Size      = new Size(300, 20);
                pnlHeading.Location  = new System.Drawing.Point(5, 5);
                pnlHeading.Text      = "Group Codes Of Level " + (level + 1);
                pnlHeading.Font      = new System.Drawing.Font("Arial", 10, FontStyle.Bold);
                pnlHeading.ForeColor = Color.Black;
                frmPopup.Controls.Add(pnlHeading);

                lv              = StockGroupDB.getListViewForStockGroup(level + 1);
                lv.Bounds       = new Rectangle(new Point(0, 25), new Size(450, 250));
                lv.ColumnClick += new ColumnClickEventHandler(LvColumnClick);
                string   children = StockGroupDB.getChildrenOfAGroup(gcode, level);
                string[] childs   = children.Split(Main.delimiter1);
                foreach (ListViewItem itemRow in lv.Items)
                {
                    if (Array.IndexOf(childs, itemRow.SubItems[1].Text) != -1)
                    {
                        itemRow.Checked = true;
                    }
                }
                frmPopup.Controls.Add(lv);

                Button lvOK = new Button();
                lvOK.BackColor = Color.Tan;
                lvOK.Text      = "OK";
                lvOK.Location  = new Point(40, 280);
                lvOK.Click    += new System.EventHandler(this.lvOK_Click1);
                frmPopup.Controls.Add(lvOK);

                Button lvCancel = new Button();
                lvCancel.BackColor = Color.Tan;
                lvCancel.Text      = "CANCEL";
                lvCancel.Location  = new Point(130, 280);
                lvCancel.Click    += new System.EventHandler(this.lvCancel_Click1);
                frmPopup.Controls.Add(lvCancel);
                frmPopup.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ListView Error");
            }
        }
示例#5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Boolean status = true;

            try
            {
                StockGroupDB sgdb = new StockGroupDB();
                stockgroup   sg   = new stockgroup();
                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");
            }
        }
示例#6
0
 private void initVariables()
 {
     StockGroupDB.fillGroupValueCombo(cmbGroup1, 1);
     CatalogueValueDB.fillCatalogValueComboNew(cmbUnit, "StockUnit");
     fillStatusCombo(cmbStatus);
 }