コード例 #1
0
ファイル: StockGroup.cs プロジェクト: suhasrake/CSLERP
 private void grdList_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex < 0)
         {
             return;
         }
         string columnName = grdList.Columns[e.ColumnIndex].Name;
         try
         {
             if (columnName.Equals("Edit"))
             {
                 //string btnText = btnSave.Text;
                 btnSave.Text             = "update";
                 prevsg                   = new stockgroup();
                 prevsg.GroupCode         = grdList.Rows[e.RowIndex].Cells["GroupCode"].Value.ToString();
                 prevsg.GroupDescription  = grdList.Rows[e.RowIndex].Cells["GroupDescription"].Value.ToString();
                 prevsg.GroupLevel        = Convert.ToInt32(cmbSelectLevel.SelectedItem.ToString().Trim());
                 txtGroupCode.Text        = prevsg.GroupCode;
                 txtGroupDescription.Text = prevsg.GroupDescription;
                 pnlAddNew.Visible        = true;
             }
         }
         catch (Exception)
         {
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #2
0
ファイル: StockGroup.cs プロジェクト: suhasrake/CSLERP
 public void clearData()
 {
     try
     {
         txtGroupCode.Text        = "";
         txtGroupDescription.Text = "";
         prevsg = new stockgroup();
     }
     catch (Exception ex)
     {
     }
 }
コード例 #3
0
 public void clearData()
 {
     try
     {
         //txtGroupCode.Text = "";
         //txtGroupDescription.Text = "";
         grdList.Rows.Clear();
         prevsg = new stockgroup();
     }
     catch (Exception ex)
     {
     }
 }
コード例 #4
0
ファイル: StockGroup.cs プロジェクト: suhasrake/CSLERP
        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");
            }
        }