示例#1
0
        private void btnAddMoney_Click(object sender, EventArgs e)
        {
            var form = new AddMoney();

            form.Show();

            refreshForm();
        }
示例#2
0
        private void btnAddMoney_Click(object sender, EventArgs e)
        {
            if (txtAccountNo.Text != string.Empty || txtAccountHolder.Text != string.Empty || txtIFSC.Text != string.Empty ||
                txtPaytmName.Text != string.Empty || txtPaytmNo.Text != string.Empty ||
                txtCCHolder.Text != string.Empty || txtCCNo.Text != string.Empty || txtCCcVV.Text != string.Empty || txtCCExpiry.Text != string.Empty ||
                txtDCHolder.Text != string.Empty || txtDCcVV.Text != string.Empty || txtDCExpiry.Text != string.Empty ||
                txtAirtelName.Text != string.Empty || txtAir.Text != string.Empty)
            {
                decimal totalAmount = 0.0m;
                string  test        = string.Empty;
                using (var connection = new SqlCeConnection(@"Data Source = |DataDirectory|\WalletDB.sdf"))
                {
                    var cmd = new SqlCeCommand();
                    cmd.Connection = connection;
                    connection.Open();
                    cmd.CommandText = "SELECT Amount from AddAmount";
                    var result = cmd.ExecuteReader();
                    while (result.Read())
                    {
                        test = result.GetValue(0).ToString();
                    }
                    if (txtAddMoneyValue.Text != string.Empty)
                    {
                        totalAmount     = Convert.ToDecimal(txtAddMoneyValue.Text) + Convert.ToDecimal(test);
                        cmd.CommandText = "insert into AddAmount(ID,Amount,Date) Values(@ID,@Amount,@Date)";
                        cmd.Parameters.AddWithValue("@ID", "UPPCL" + s);
                        cmd.Parameters.AddWithValue("@Amount", totalAmount);
                        cmd.Parameters.AddWithValue("@Date", s);
                        int x = cmd.ExecuteNonQuery();
                        if (x > 0)
                        {
                            refreshForm();
                            string message = "Amount added successfully";
                            MessageBox.Show(message);
                            cmd.CommandText = "insert into AvailableBalance(ID,Balance,Status,AddedBy,Date) Values(@IDAB,@Balance,@Status,@AddedBy,@DateAB)";
                            cmd.Parameters.AddWithValue("@IDAB", "UPPCL" + s);
                            cmd.Parameters.AddWithValue("@Balance", txtAddMoneyValue.Text);
                            cmd.Parameters.AddWithValue("@Status", "Added");

                            if (cmbPaymentMethod.SelectedIndex == 1)
                            {
                                cmd.Parameters.AddWithValue("@AddedBy", "Paytm Wallet");
                            }
                            else if (cmbPaymentMethod.SelectedIndex == 2)
                            {
                                cmd.Parameters.AddWithValue("@AddedBy", "NetBanking");
                            }
                            else if (cmbPaymentMethod.SelectedIndex == 3)
                            {
                                cmd.Parameters.AddWithValue("@AddedBy", "Credit Card");
                            }
                            else if (cmbPaymentMethod.SelectedIndex == 4)
                            {
                                cmd.Parameters.AddWithValue("@AddedBy", "Debit Card");
                            }
                            else if (cmbPaymentMethod.SelectedIndex == 5)
                            {
                                cmd.Parameters.AddWithValue("@AddedBy", "Airtel Wallet");
                            }

                            cmd.Parameters.AddWithValue("@DateAB", s);

                            x = cmd.ExecuteNonQuery();
                            var form = new AddMoney();
                            this.Close();
                            // string s = Convert.ToString(totalAmount);
                            Details detailForm = new Details();
                            detailForm.refreshForm();
                            //detailForm.lblWalletBalanceValue.Text = this.lblWalletBalance.Text;
                            //Form f = new Details();
                            //foreach (Control c in f.Controls)
                            //    if (c.Name == "lblWalletBalanceValue")
                            //    {
                            //        c.Text = Convert.ToString(totalAmount);
                            //        return;
                            //    }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter money");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter details");
            }
        }
示例#3
0
        private void btnPayMoney_Click(object sender, EventArgs e)
        {
            if (txtBillNo.Text == string.Empty || txtConsumerNo.Text == string.Empty || txtAmount.Text == string.Empty)
            {
                string message = "All Fields are mandatory";
                MessageBox.Show(message);
            }
            else
            {
                string test = string.Empty;
                using (var connection = new SqlCeConnection(@"Data Source = |DataDirectory|\WalletDB.sdf"))
                {
                    var cmd = new SqlCeCommand();
                    cmd.Connection = connection;
                    connection.Open();
                    cmd.CommandText = "SELECT Amount from AddAmount";
                    var result = cmd.ExecuteReader();
                    while (result.Read())
                    {
                        test = result.GetValue(0).ToString();
                    }

                    if (!(string.IsNullOrEmpty(txtAmount.Text)))
                    {
                        if (Convert.ToDecimal(test) >= Convert.ToDecimal(txtAmount.Text))
                        {
                            decimal totalAmount = Convert.ToDecimal(test) - Convert.ToDecimal(txtAmount.Text);
                            cmd.CommandText = "insert into BillPaid(ID,Amount,ConsumerNo,BillNo,Date,Status) Values(@ID,@Amount,@ConsumerNo,@BillNo,@Date,@Status) ";
                            cmd.Parameters.AddWithValue("@ID", "UPPCL" + txtConsumerNo.Text);
                            cmd.Parameters.AddWithValue("@Amount", txtAmount.Text);
                            cmd.Parameters.AddWithValue("@ConsumerNo", txtConsumerNo.Text);
                            cmd.Parameters.AddWithValue("@BillNo", txtBillNo.Text);
                            cmd.Parameters.AddWithValue("@Date", s);
                            cmd.Parameters.AddWithValue("@Status", "Paid");

                            int x = cmd.ExecuteNonQuery();
                            if (x > 0)
                            {
                                string message = "Amount paid successfully";
                                MessageBox.Show(message);
                                cmd.CommandText = "insert into AvailableBalance(ID,Balance,Status,PaidTo,Date) Values(@ID,@Balance,@Status,@PaidTo,@Date) ";
                                cmd.Parameters.Clear();
                                cmd.Parameters.AddWithValue("@ID", "UPPCL" + System.DateTime.Now);
                                cmd.Parameters.AddWithValue("@Balance", txtAmount.Text);
                                cmd.Parameters.AddWithValue("@Status", "Paid");
                                cmd.Parameters.AddWithValue("@PaidTo", txtConsumerNo.Text);
                                cmd.Parameters.AddWithValue("@Date", s);

                                x = cmd.ExecuteNonQuery();

                                cmd.CommandText = "insert into AddAmount(ID,Amount,Date) Values(@IDA,@Amount,@DateA)";
                                cmd.Parameters.AddWithValue("@IDA", "UPPCL" + System.DateTime.Now);
                                cmd.Parameters.AddWithValue("@Amount", totalAmount);
                                cmd.Parameters.AddWithValue("@DateA", s);

                                x = cmd.ExecuteNonQuery();

                                BillDue();
                                refreshForm();
                                txtAmount.Text      = string.Empty;
                                txtConsumerNo.Text  = string.Empty;
                                txtBillNo.Text      = string.Empty;
                                txtPaymentDate.Text = string.Empty;

                                if (!(x > 0))
                                {
                                    message = "Amount is not deducted";
                                    MessageBox.Show(message);
                                    var form = new AddMoney();
                                    this.Close();
                                }
                            }

                            //update availble balance
                        }
                        else
                        {
                            string message = "Wallet balance is not sufficient";
                            MessageBox.Show(message);
                            txtAmount.Text      = string.Empty;
                            txtConsumerNo.Text  = string.Empty;
                            txtBillNo.Text      = string.Empty;
                            txtPaymentDate.Text = string.Empty;
                            refreshForm();
                        }
                    }

                    else
                    {
                        refreshForm();
                        string message = "Please add amount";
                        MessageBox.Show(message);
                        txtAmount.Text      = string.Empty;
                        txtConsumerNo.Text  = string.Empty;
                        txtBillNo.Text      = string.Empty;
                        txtPaymentDate.Text = string.Empty;
                    }
                }
            }
        }