示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ModCommonClasses.con = new SqlConnection(ModCS.cs);
                ModCommonClasses.con.Open();
                string cb = "insert into InvoiceInfo1(TransactionID, Date, AccountID, AccountName, Mobile,Status,Outdate,PaymentMode,Oldbalance,Amount,Balance,Remarks) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11,@d12)";
                ModCommonClasses.cmd = new SqlCommand(cb);

                ModCommonClasses.cmd.Parameters.AddWithValue("@d1", txtTransactionNo.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d2", dtpTranactionDate.Text);

                ModCommonClasses.cmd.Parameters.AddWithValue("@d3", txtID.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d4", txtAccountName.Text);

                ModCommonClasses.cmd.Parameters.AddWithValue("@d5", txtContactNo.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d6", cmbStatus.Text);

                ModCommonClasses.cmd.Parameters.AddWithValue("@d7", dtpMobileOutDate.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d8", cmbPaymentMode.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d9", txt_old_bal.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d10", txt_paid_amount.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d11", txt_dues.Text);
                ModCommonClasses.cmd.Parameters.AddWithValue("@d12", txtRemarks.Text);

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



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


                if (cmbPaymentMode.SelectedIndex == 1 | cmbPaymentMode.SelectedIndex == 2)
                {
                    ModFunc.ServicesLedgerBook(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();
                DisplayData2();
                ClearData2();
                btnSave.Enabled = false;
                ModCommonClasses.con.Close();
                this.ActiveControl = txtAccountID;
                txtAccountID.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }