Beispiel #1
0
 private void TxtInv_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         TxtJob.Focus();
     }
 }
Beispiel #2
0
        private void txtigst_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.'))
            {
                e.Handled = true;
            }

            // only allow one decimal point
            if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
            {
                e.Handled = true;
            }

            if (e.KeyChar == 13)
            {
                calculatenet();
                if (String.IsNullOrEmpty(TxtInv.Text) || String.IsNullOrEmpty(TxtJob.Text) || String.IsNullOrEmpty(txtinvdate.Text) ||
                    String.IsNullOrEmpty(TxtInvValue.Text) || string.IsNullOrEmpty(txtsgst.Text) || (string.IsNullOrEmpty(txtcgst.Text) &&
                                                                                                     string.IsNullOrEmpty(txtigst.Text)))
                {
                    MessageBox.Show(" Highlighted Fields can not be left blank.");
                    if (String.IsNullOrEmpty(TxtInv.Text))
                    {
                        TxtInv.Focus();
                    }
                    if (String.IsNullOrEmpty(TxtJob.Text))
                    {
                        TxtJob.Focus();
                    }
                    if (String.IsNullOrEmpty(txtinvdate.Text))
                    {
                        txtinvdate.Focus();
                    }
                    if (String.IsNullOrEmpty(TxtInvValue.Text))
                    {
                        TxtInvValue.Focus();
                    }
                    if (String.IsNullOrEmpty(txtsgst.Text))
                    {
                        txtsgst.Focus();
                    }
                }
                else
                {
                    try
                    {
                        SqlCommand check_Inv_No = new SqlCommand("SELECT COUNT(*) FROM TblCreditorInvMast WHERE InvNo = @inv and finyr=@finyear " +
                                                                 "and brcode=@branchcode and glid=@mglid and slid=@mslid", clsConnection.Conn);
                        check_Inv_No.Parameters.AddWithValue("@inv", TxtInv.Text);
                        check_Inv_No.Parameters.AddWithValue("@finyear", Global.finyr);
                        check_Inv_No.Parameters.AddWithValue("@Branchcode", Global.branch);
                        check_Inv_No.Parameters.AddWithValue("@mglid", label8.Text);
                        check_Inv_No.Parameters.AddWithValue("@mslid", label9.Text);
                        int InvExist = (int)check_Inv_No.ExecuteScalar();

                        if (InvExist > 0)
                        {
                            MessageBox.Show("Same Invoice No. already exist for this credior in this financial year.");
                            TxtInv.Text      = "";
                            TxtJob.Text      = "";
                            txtinvdate.Text  = "";
                            TxtInvValue.Text = "0.00";
                            txtothers.Text   = "0.00";
                            txtdiscount.Text = "0.00";
                            txtsgst.Text     = "0.00";
                            txtcgst.Text     = "0.00";
                            txtigst.Text     = "0.00";
                            textnet.Text     = "0.00";
                            TxtInv.Focus();
                        }
                        else
                        {
                            if (dataGridView1.Rows.Count == 0)
                            {
                                dataGridView1.Rows[0].Cells[0].Value = TxtInv.Text;
                                dataGridView1.Rows[0].Cells[1].Value = TxtJob.Text;
                                dataGridView1.Rows[0].Cells[2].Value = Convert.ToString(txtinvdate.Text);
                                dataGridView1.Rows[0].Cells[3].Value = TxtInvValue.Text;
                                dataGridView1.Rows[0].Cells[4].Value = txtothers.Text;
                                dataGridView1.Rows[0].Cells[5].Value = txtdiscount.Text;
                                dataGridView1.Rows[0].Cells[6].Value = txtsgst.Text;
                                dataGridView1.Rows[0].Cells[7].Value = txtcgst.Text;
                                dataGridView1.Rows[0].Cells[8].Value = txtigst.Text;
                                dataGridView1.Rows[0].Cells[9].Value = textnet.Text;
                                dataGridView1.Rows.Add();
                            }
                            else
                            {
                                Int32 i = dataGridView1.Rows.Count - 1;
                                dataGridView1.Rows.Add();
                                dataGridView1.Rows[i].Cells[0].Value = TxtInv.Text;
                                dataGridView1.Rows[i].Cells[1].Value = TxtJob.Text;
                                dataGridView1.Rows[i].Cells[2].Value = Convert.ToString(txtinvdate.Text);
                                dataGridView1.Rows[i].Cells[3].Value = TxtInvValue.Text;
                                dataGridView1.Rows[i].Cells[4].Value = txtothers.Text;
                                dataGridView1.Rows[i].Cells[5].Value = txtdiscount.Text;
                                dataGridView1.Rows[i].Cells[6].Value = txtsgst.Text;
                                dataGridView1.Rows[i].Cells[7].Value = txtcgst.Text;
                                dataGridView1.Rows[i].Cells[8].Value = txtigst.Text;
                                dataGridView1.Rows[i].Cells[9].Value = textnet.Text;
                            }
                            TxtInv.Text      = "";
                            TxtJob.Text      = "";
                            txtinvdate.Text  = "";
                            TxtInvValue.Text = "0.00";
                            txtothers.Text   = "0.00";
                            txtdiscount.Text = "0.00";
                            txtsgst.Text     = "0.00";
                            txtcgst.Text     = "0.00";
                            txtigst.Text     = "0.00";
                            textnet.Text     = "0.00";
                            TxtInv.Focus();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }