Exemplo n.º 1
0
        public static void CreatePayment(clsPaymentInfo pay)
        {
            string        connectionString = DataManager.OraConnString();
            SqlConnection sqlCon           = new SqlConnection(connectionString);
            string        query            = "insert into payment_info (pay_id, pay_head_id,pay_type,pay_class,for_all_std,pay_amt,discount,version,GroupID) values ( '" + pay.PayId + "', '" + pay.PayName + "', '" + pay.PayType + "',convert(numeric,nullif('" + pay.PayClass + "','')),'" + pay.ForAllStd + "', convert(decimal(13,2),nullif('" + pay.PayAmt + "','')),'" + pay.Discount + "','" + pay.Version + "','" + pay.GroupID + "')";

            DataManager.ExecuteNonQuery(connectionString, query);
        }
Exemplo n.º 2
0
        public static void UpdatePayment(clsPaymentInfo pay)
        {
            string        connectionString = DataManager.OraConnString();
            SqlConnection sqlCon           = new SqlConnection(connectionString);
            string        query            = "update payment_info set pay_head_id='" + pay.PayName + "',pay_type='" + pay.PayType + "',pay_class=convert(numeric,nullif('" + pay.PayClass + "','')),for_all_std='" + pay.ForAllStd + "' ,pay_amt=convert(decimal(13,2),nullif('" + pay.PayAmt + "','')), discount='" + pay.Discount + "',version='" + pay.Version + "',GroupID='" + pay.GroupID + "' where pay_id='" + pay.PayId + "'";

            DataManager.ExecuteNonQuery(connectionString, query);
        }
Exemplo n.º 3
0
        private void AddPaymentsReceivedItemToGrid(clsPaymentInfo payment)
        {
            int rowidx = dgvPayments.Rows.Add();

            dgvPayments.Rows[rowidx].Cells[0].Value = payment.Timestamp;
            dgvPayments.Rows[rowidx].Cells[1].Value = payment.AccountName;
            dgvPayments.Rows[rowidx].Cells[2].Value = payment.AmountPaid;
            dgvPayments.Rows[rowidx].Cells[3].Value = payment.UserName;
        }
Exemplo n.º 4
0
        private void AddItemToGrid(clsPaymentInfo fitem)
        {
            int rowidx = dgvPayments.Rows.Add();

            dgvPayments.Rows[rowidx].Cells[0].Value = fitem.Timestamp;
            dgvPayments.Rows[rowidx].Cells[1].Value = fitem.AccountName;
            dgvPayments.Rows[rowidx].Cells[2].Value = fitem.AmountPaid;
            dgvPayments.Rows[rowidx].Cells[3].Value = fitem.Remarks;
            dgvPayments.Rows[rowidx].Cells[4].Value = fitem.UserName;
        }
Exemplo n.º 5
0
 protected void dgPay_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     try
     {
         if (per.AllowEdit == "Y")
         {
             clsPaymentInfo pay = clsPaymentInfoManager.getPayment(((TextBox)dgPay.Rows[e.RowIndex].FindControl("txtPayId")).Text);
             if (pay != null)
             {
                 pay.PayName   = ((DropDownList)dgPay.Rows[e.RowIndex].FindControl("ddlPayHead")).SelectedValue.Trim();
                 pay.PayType   = ((DropDownList)dgPay.Rows[e.RowIndex].FindControl("ddlPayType")).SelectedValue.Trim();
                 pay.ForAllStd = ((DropDownList)dgPay.Rows[e.RowIndex].FindControl("ddlForAllStd")).SelectedValue.Trim();
                 pay.PayClass  = ((DropDownList)dgPay.Rows[e.RowIndex].FindControl("ddlPayClass")).SelectedValue.Trim();
                 pay.Discount  = ((DropDownList)dgPay.Rows[e.RowIndex].FindControl("ddlDiscount")).SelectedValue.Trim();
                 pay.PayAmt    = ((TextBox)dgPay.Rows[e.RowIndex].FindControl("txtPayAmt")).Text;
                 pay.Version   = ((DropDownList)dgPay.Rows[e.RowIndex].FindControl("ddlVersion")).SelectedValue.Trim();
                 pay.GroupID   = ((DropDownList)dgPay.Rows[e.RowIndex].FindControl("ddlGroup")).SelectedValue.Trim();
                 clsPaymentInfoManager.UpdatePayment(pay);
             }
             DataTable dt = (DataTable)Session["Payment"];
             if (dt.Rows.Count > 0)
             {
                 dgPay.DataSource = dt;
                 dgPay.EditIndex  = -1;
                 dgPay.DataBind();
             }
             else
             {
                 getEmptyGrid();
             }
             ClientScript.RegisterStartupScript(this.GetType(), "ale", "alert('Record udpated successfully!!');", true);
         }
     }
     catch (FormatException fex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('" + fex.Message + "');", true);
     }
     catch (Exception ex)
     {
         if (ex.Message.Contains("Database"))
         {
             ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('Database Maintain Error. Contact to the Software Provider..!!');", true);
         }
         else
         {
             ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('There is some problem to do the task. Try again properly.!!');", true);
         }
     }
 }
Exemplo n.º 6
0
    protected void dgPay_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "AddNew")
            {
                //DataTable dt = clsPaymentInfoManager.GetPayments();
                DataTable dt = (DataTable)Session["Payment"];
                dgPay.DataSource = dt;
                dgPay.DataBind();
                dgPay.ShowFooter        = true;
                dgPay.FooterRow.Visible = true;
                ((TextBox)dgPay.FooterRow.FindControl("txtPayId")).Text = IdManager.GetNextID("payment_info", "Pay_id").ToString();
                //((TextBox)dgPay.FooterRow.FindControl("txtPayName")).Focus();
                ((TextBox)dgPay.FooterRow.FindControl("txtPayAmt")).Text = "0";
                ((DropDownList)dgPay.FooterRow.FindControl("ddlPayClass")).Items.Clear();

                string queryDist = "select class_id,class_name from class_info order by 1";
                util.PopulationDropDownList(((DropDownList)dgPay.FooterRow.FindControl("ddlPayClass")), "Class", queryDist, "class_name", "class_id");
                ((DropDownList)dgPay.FooterRow.FindControl("ddlPayClass")).Items.Insert(0, "");

                ((DropDownList)dgPay.FooterRow.FindControl("ddlVersion")).Items.Clear();
                //string queryVersion = "select '' id, 'Select Version' version_name  union select id,version_name from version_info order by 1";
                //util.PopulationDropDownList(((DropDownList)dgPay.FooterRow.FindControl("ddlVersion")), "Verson", queryVersion, "version_name", "id");
                string queryHead = "select '' id, 'Select Head' Head_Name  union select id,Head_Name from payment_head order by 1";
                util.PopulationDropDownList(((DropDownList)dgPay.FooterRow.FindControl("ddlPayHead")), "PayHead", queryHead, "Head_Name", "id");
            }
            else if (e.CommandName == "Insert")
            {
                clsPaymentInfo pay = new clsPaymentInfo();
                pay.PayId     = ((TextBox)dgPay.FooterRow.FindControl("txtPayId")).Text.Trim();
                pay.PayName   = ((DropDownList)dgPay.FooterRow.FindControl("ddlPayHead")).SelectedValue.Trim();
                pay.PayType   = ((DropDownList)dgPay.FooterRow.FindControl("ddlPayType")).SelectedValue.Trim();
                pay.PayClass  = ((DropDownList)dgPay.FooterRow.FindControl("ddlPayClass")).SelectedValue.Trim();
                pay.ForAllStd = ((DropDownList)dgPay.FooterRow.FindControl("ddlForAllStd")).SelectedValue.Trim();
                pay.PayAmt    = ((TextBox)dgPay.FooterRow.FindControl("txtPayAmt")).Text.Trim();
                pay.Discount  = ((DropDownList)dgPay.FooterRow.FindControl("ddlDiscount")).SelectedValue.Trim();
                pay.Version   = ((DropDownList)dgPay.FooterRow.FindControl("ddlVersion")).SelectedValue.Trim();
                pay.GroupID   = ((DropDownList)dgPay.FooterRow.FindControl("ddlGroup")).SelectedValue.Trim();
                if (per.AllowAdd == "Y")
                {
                    clsPaymentInfoManager.CreatePayment(pay);
                }
                //DataTable dt = clsPaymentInfoManager.GetPayments();
                DataTable dt = (DataTable)Session["Payment"];
                if (dt.Rows.Count > 0)
                {
                    dgPay.DataSource = dt;
                    dgPay.EditIndex  = -1;
                    dgPay.DataBind();
                    dgPay.FooterRow.Visible = false;
                    dgPay.ShowFooter        = false;
                }
                else
                {
                    getEmptyGrid();
                }
                ClientScript.RegisterStartupScript(this.GetType(), "ale", "alert('Record created successfully!!');", true);
            }
        }
        catch (FormatException fex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('" + fex.Message + "');", true);
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("Database"))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('Database Maintain Error. Contact to the Software Provider..!!');", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('There is some problem to do the task. Try again properly.!!');", true);
            }
        }
    }
Exemplo n.º 7
0
        private bool CancelPayment()
        {
            if (!clsUtil.GetApproval(m_user, UserAccess.Manager))
            {
                return(false);
            }
            frmSelectAccounts acct = new frmSelectAccounts(0, m_user);

            if (acct.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                clsAccountInfo a = acct.SelectedAccount;

                frmInput input = new frmInput();
                input.Title         = "Retrieve Payment Info";
                input.Caption       = "Payment Reference";
                input.IsHiddenInput = false;
                input.IsNumericOnly = true;
                input.withDecimal   = false;
                input.Value         = "";
                if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    clsPaymentInfo payment = clsPaymentInfo.GetPayment(Convert.ToInt32(input.Value));
                    if (payment != null)
                    {
                        clsChargedTransaction charges = clsChargedTransaction.GetChargedTransaction(payment.OrNum);

                        if (charges != null && payment.PaymentId != 0 && payment.AccountId == a.AccountId)
                        {
                            if (payment.Remarks.ToLower().Contains("interest"))
                            {
                                MessageBox.Show("Interest payment cancellation not allowed!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                            else if (MessageBox.Show(string.Format("Are you sure you want to cancel payment?\nRefno:{0}\nRemarks:{1}\nAmount:P {2:0.00}", payment.PaymentId, payment.Remarks, payment.AmountPaid), "Cancel Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                            {
                                if (payment.Remarks.ToLower().Contains("principal"))
                                {
                                    a.PrincipalBalance += payment.AmountPaid;
                                    a.Save();
                                    charges.TransBalance += payment.AmountPaid;
                                    charges.SaveChargeTransaction();

                                    if (clsPaymentInfo.CancelPayment(payment.PaymentId))
                                    {
                                        MessageBox.Show("Payment successfully cancelled!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Cancel Payment did not succeed!", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Payment Reference not found under this account", "Cancel Payment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        private void btnPayment_Click(object sender, EventArgs e)
        {
            if (dgvAccounts.SelectedRows.Count > 0)
            {
                if (m_Accounts != null)
                {
                    foreach (clsAccountInfo a in m_Accounts)
                    {
                        if (a.AccountName == dgvAccounts.SelectedRows[0].Cells[1].Value.ToString())
                        {
                            frmInput payment    = new frmInput();
                            double   amountpaid = a.AccountReceivable;
                            double   change     = 0;
                            payment.Title         = "Cash Payment";
                            payment.Caption       = "Amount";
                            payment.IsNumericOnly = true;
                            payment.Value         = a.AccountReceivable.ToString();
                            if (payment.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                if (Convert.ToDouble(payment.Value) < a.AccountReceivable)
                                {
                                    amountpaid = Convert.ToDouble(payment.Value);
                                }
                                else
                                {
                                    amountpaid = a.AccountReceivable;
                                    change     = Convert.ToDouble(payment.Value) - a.AccountReceivable;
                                }
                                if (amountpaid > 0)
                                {
                                    clsPaymentInfo pay = new clsPaymentInfo();
                                    pay.AccountId  = a.AccountId;
                                    pay.AmountPaid = amountpaid;
                                    pay.Timestamp  = DateTime.Now;
                                    pay.UserId     = m_user.UserId;
                                    pay.UserName   = m_user.UserName;
                                    string  reference = pay.Save();
                                    string  ret       = "";
                                    Receipt or        = new Receipt();
                                    or.InitializePrinter();
                                    List <string> strmsg = new List <string>();
                                    ret += or.PrintCompanyHeader();
                                    strmsg.Add("");
                                    strmsg.Add("PAYMENT");
                                    ret += or.PrintHeader(strmsg, PrintFontAlignment.Center, PrintFontSize.UnderlineBold);
                                    strmsg.Clear();

                                    strmsg.Add(string.Format("Cashier: {0}", m_user.UserName.ToUpper()));
                                    strmsg.Add(string.Format("Date: {0}", pay.Timestamp.ToString("yyyy-MM-dd HH:mm:ss")));
                                    strmsg.Add(reference);
                                    strmsg.Add(string.Format("Account Name: {0}", a.AccountName));
                                    strmsg.Add(string.Format("Previous Balance: {0}", a.AccountReceivable));
                                    strmsg.Add(string.Format("Amount Paid: {0}", amountpaid));
                                    strmsg.Add(string.Format("Current Balance: {0}", a.AccountReceivable - amountpaid));

                                    a.LoadTransInfo();
                                    //a.PrincipalBalance = clsChargedTransaction.GetPrincipalAmount(a.AccountId);
                                    // a.TotalInterest = clsChargedTransaction.GetTotalInterest(a.AccountId);
                                    a.LastComputedInterest = DateTime.Today;
                                    a.Save();

                                    ret += or.PrintAppend(strmsg, PrintFontAlignment.Left, PrintFontSize.Regular);
                                    or.FormFeed();
                                    or.OpenDrawer();
                                    or.ExecPrint(ret);
                                    strmsg.Clear();

                                    CloseDrawer drawer = new CloseDrawer();
                                    drawer.Change = change;
                                    drawer.ShowDialog();
                                    DisplayAccounts(txtSearch.Text);
                                }
                            }
                        }
                    }
                }
            }
        }