Esempio n. 1
0
        private void btnSave1_Click(object sender, EventArgs e)
        {
            try
            {
                ModCommonClasses.con = new SqlConnection(ModCS.cs);
                ModCommonClasses.con.Open();
                string cb = "insert into Payment(TransactionID, Date, PaymentMode, AccountID, Oldbalance,Amount,Balanceamount,PaymentModeDetails) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8)";
                ModCommonClasses.cmd = new SqlCommand(cb);

                ModCommonClasses.cmd.Parameters.AddWithValue("@d1", txtTransactionNo.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d2", dtpTranactionDate.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d3", cmbPaymentMode.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d4", txtID.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d5", txt_old_bal.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d6", txt_paid_amount.Text);

                ModCommonClasses.cmd.Parameters.AddWithValue("@d7", txt_dues.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d8", txtPaymentModeDetails.Text);

                ModCommonClasses.cmd.Connection = ModCommonClasses.con;
                ModCommonClasses.cmd.ExecuteNonQuery();
                ModCommonClasses.con.Close();



                if (cmbPaymentMode.SelectedIndex == 0)
                {
                    ModFunc.CustomerLedgerSaveInvoice(dtpTranactionDate.Text, txtAccountID.Text, "Cash Account", "Payment", Convert.ToDecimal(txt_paid_amount.Text), 0, txtContactNo.Text);
                }


                if (cmbPaymentMode.SelectedIndex == 1 | cmbPaymentMode.SelectedIndex == 2)
                {
                    ModFunc.CustomerLedgerSaveInvoice(dtpTranactionDate.Text, txtAccountID.Text, "Bank Account", "Payment to " + txtAccountName.Text + "", Convert.ToDecimal(txt_paid_amount.Text), 0, txtContactNo.Text);
                }



                if (cmbPaymentMode.SelectedIndex == 0)
                {
                    ModFunc.LedgerSave(dtpTranactionDate.Text, txtAccountID.Text, "Cash Account", "Payment", Convert.ToDecimal(txt_paid_amount.Text), 0, txtContactNo.Text);
                }


                if (cmbPaymentMode.SelectedIndex == 1 | cmbPaymentMode.SelectedIndex == 2)
                {
                    ModFunc.LedgerSave(dtpTranactionDate.Text, txtAccountID.Text, "Bank Account", "Payment to " + txtAccountName.Text + "", Convert.ToDecimal(txt_paid_amount.Text), 0, txtContactNo.Text);
                }



                ModFunc.LogFunc(lblUser.Text, "Added the New Payment Having Transaction No. '" + txtTransactionNo.Text + "'");
                MessageBox.Show("Successfully Saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                transid();
                DisplayData1();
                ClearData1();
                btnSave.Enabled = false;
                ModCommonClasses.con.Close();
                this.ActiveControl = txtAccountID;
                txtAccountID.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }