Пример #1
0
        private void BtnOK_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                if (BtnOK.Text.Trim().ToUpper() == "&OK")
                {
                    DataRow NewRow = dt.NewRow();

                    NewRow["PrdCode"]     = Convert.ToDecimal(txtPrdCode.Text);
                    NewRow["PrdAsgnCode"] = txtPrdAsgnCode.Text.Trim();
                    NewRow["PrdName"]     = txtProductName.Text.Trim();
                    NewRow["Quantity"]    = Convert.ToDecimal(txtQty.Text);
                    dt.Rows.Add(NewRow);
                    if (dt.Rows.Count > 0)
                    {
                        InfoGrid.DataSource = dt;
                        InfoGridView.BestFitColumns();
                    }
                    else
                    {
                        InfoGrid.DataSource = null;
                    }
                    BtnUndo.PerformClick();
                }
                if (BtnOK.Text.Trim().ToUpper() == "&UPDATE")
                {
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdCode"], Convert.ToDecimal(txtPrdCode.Text));
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdAsgnCode"], txtPrdAsgnCode.Text.Trim());
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdName"], txtProductName.Text.Trim());
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Quantity"], Convert.ToDecimal(txtQty.Text));
                    InfoGridView.RefreshData();
                    BtnUndo.PerformClick();
                }
            }
        }
Пример #2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case (Keys.Control | Keys.N):
            {
                BtnAddNew.PerformClick(); break;
            }

            case (Keys.Control | Keys.E):
            {
                BtnEdit.PerformClick(); break;
            }

            case (Keys.Control | Keys.D):
            {
                BtnDelete.PerformClick(); break;
            }

            case (Keys.Control | Keys.S):
            {
                BtnSave.PerformClick(); break;
            }

            case (Keys.Control | Keys.U):
            {
                BtnUndo.PerformClick(); break;
            }

            case (Keys.Control | Keys.F):
            {
                BtnFind.PerformClick(); break;
            }

            case (Keys.Control | Keys.R):
            {
                BtnReload.PerformClick(); break;
            }

            case (Keys.Control | Keys.P):
            {
                BtnPrint.PerformClick(); break;
            }
            }
            return(base.ProcessCmdKey(ref msg, keyData));
        }
        private void BtnOK_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                InfoGrid.RefreshDataSource();

                if (BtnOK.Text.ToUpper() == "&OK")
                {
                    InfoGrid.RefreshDataSource();
                    var dr = dt.NewRow();
                    dr["PrdCode"]     = Convert.ToDecimal(txtProductCode.Text);
                    dr["PrdAsgnCode"] = txtProductACode.Text;
                    dr["PrdName"]     = txtProductName.Text;
                    dr["Qty"]         = Convert.ToDecimal(txtProductQty.Text);
                    dr["Amount"]      = Convert.ToDecimal(txtAmount.Text);
                    dt.Rows.Add(dr);
                    if (dt.Rows.Count > 0)
                    {
                        InfoGrid.DataSource = dt;
                        InfoGridView.BestFitColumns();
                    }
                    BtnUndo.PerformClick();
                }
                if (BtnOK.Text.ToUpper() == "&UPDATE")
                {
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdCode"], Convert.ToDecimal(txtProductCode.Text));
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdAsgnCode"], txtProductACode.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdName"], txtProductName.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Qty"], Convert.ToDecimal(txtProductQty.Text));
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Amount"], Convert.ToDecimal(txtAmount.Text));
                    InfoGridView.RefreshData();

                    BtnUndo.PerformClick();
                }
            }
        }
        private void BtnOK_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                InfoGrid.RefreshDataSource();
                if (BtnOK.Text.ToUpper() == "&OK")
                {
                    InfoGrid.RefreshDataSource();
                    var dr = dt.NewRow();
                    dr["AccCode"]   = txtAccCode.Text.Trim();
                    dr["AccName"]   = txtAccName.Text;
                    dr["Narration"] = txtNarration.Text;
                    if (txtDrCr.Text.ToUpper() == "DR")
                    {
                        dr["Debit"] = Convert.ToDecimal(txtAmount.Text);
                    }
                    else
                    {
                        dr["Debit"] = Convert.ToDecimal("0");
                    }
                    if (txtDrCr.Text.ToUpper() == "CR")
                    {
                        dr["Credit"] = Convert.ToDecimal(txtAmount.Text);
                    }
                    else
                    {
                        dr["Credit"] = Convert.ToDecimal("0");
                    }
                    dr["CrDr"]        = txtDrCr.Text;
                    dr["VutChequeNo"] = txtChqNo.Text;
                    if (txtChqDate.Text.Length > 0)
                    {
                        dr["VutChequeDate"] = Convert.ToDateTime(txtChqDate.Text).ToString("yyyy-MM-dd");
                    }
                    dt.Rows.Add(dr);
                    if (dt.Rows.Count > 0)
                    {
                        InfoGrid.DataSource = dt;
                        InfoGridView.BestFitColumns();
                    }
                }


                if (BtnOK.Text.ToUpper() == "&UPDATE")
                {
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["AccCode"], txtAccCode.Text.Trim());
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["AccName"], txtAccName.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Narration"], txtNarration.Text);
                    if (txtDrCr.Text.ToUpper() == "DR")
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Debit"], Convert.ToDecimal(txtAmount.Text));
                    }
                    else
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Debit"], Convert.ToDecimal("0"));
                    }
                    if (txtDrCr.Text.ToUpper() == "CR")
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Credit"], Convert.ToDecimal(txtAmount.Text));
                    }
                    else
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Credit"], Convert.ToDecimal("0"));
                    }
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["CrDr"], txtDrCr.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["VutChequeNo"], txtChqNo.Text);
                    if (txtChqDate.Text.Length > 0)
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["VutChequeDate"], Convert.ToDateTime(txtChqDate.Text));
                    }
                    InfoGridView.RefreshData();
                    BtnUndo.PerformClick();
                }
            }
        }