コード例 #1
0
        public IHttpActionResult DeleteAndUpdatePayment(PaymentModels payment)
        {
            SqlDataReader SqlDtr;
            string        sql;

            sql    = "delete from payment_transaction where voucher_id = " + payment.VoucherId;
            SqlDtr = obj.GetRecordSet(sql);
            SqlDtr.Close();

            sql    = "delete from AccountsLedgerTable where Particulars = 'Payment (" + payment.VoucherId + ")'";
            SqlDtr = obj.GetRecordSet(sql);
            SqlDtr.Close();

            if (payment.OldCust_ID != "")
            {
                sql    = "delete from CustomerLedgerTable where Particular = 'Voucher(" + payment.VoucherId + ")' and CustID='" + payment.OldCust_ID + "'";
                SqlDtr = obj.GetRecordSet(sql);
                SqlDtr.Close();
            }

            sql    = "insert into payment_transaction values(" + payment.Vouch_ID + ",'Payment'," + payment.Ledger_ID1 + "," + payment.Amount1 + "," + payment.By_ID1 + "," + payment.Amount1 + ",'" + payment.Bank_name1 + "','" + payment.Cheque_No1 + "',CONVERT(datetime,'" + payment.dtDate + "', 103),'" + payment.narration1 + "','" + payment.uid + "',CONVERT(datetime,'" + payment.Entry_Date + "', 103))";
            SqlDtr = obj.GetRecordSet(sql);
            SqlDtr.Close();
            object obj1 = null;

            dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProInsertAccountsLedger", ref obj1, "@Ledger_ID", payment.Ledger_ID1, "@Particulars", "Payment (" + payment.Vouch_ID + ")", "@Debit_Amount", payment.Amount1, "@Credit_Amount", "0.0", "@type", "Dr", "@Invoice_Date", payment.Entry_Date);
            //dbobj.ExecProc(DBOperations.OprType.Insert, "ProInsertAccountsLedger", ref obj1, "@Ledger_ID", payment.By_ID1, "@Particulars", "Payment (" + payment.Vouch_ID + ")", "@Debit_Amount", "0.0", "@Credit_Amount", payment.Amount1, "@type", "Cr", "@Invoice_Date", payment.Entry_Date);
            dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProCustomerLedgerEntry", ref obj1, "@Voucher_ID", payment.Vouch_ID, "@Ledger_ID", payment.Ledger_ID1, "@Amount", payment.Amount1, "@Type", "Dr.", "@Invoice_Date", payment.Entry_Date);
            //dbobj.ExecProc(DBOperations.OprType.Insert, "ProCustomerLedgerEntry", ref obj1, "@Voucher_ID", payment.Vouch_ID, "@Ledger_ID", payment.By_ID1, "@Amount", payment.Amount1, "@Type", "Cr.", "@Invoice_Date", payment.Entry_Date);
            if (payment.Equals(0) || payment == null)
            {
                return(Content(HttpStatusCode.NotFound, "Payment Not Updated"));
            }
            return(Ok(payment));
        }
コード例 #2
0
        public ActionResult Payment(PaymentModels model)
        {
            if (ModelState.IsValid)
            {
                Session["Paid"] = "true";
                return(Redirect("success"));
            }

            return(Redirect("payment"));
        }
コード例 #3
0
        public ActionResult Payment([Bind(Include = "Id,No,Source_BankAccounts_Id,Target_BankAccounts_Id,Amount,ConfirmationNumber,Notes,IdUser,HasPayment")] PaymentViewModels paymentVM)
        {
            Common.Master m         = new Common.Master();
            decimal       remaining = db.Payroll.Where(x => x.Id == paymentVM.Id).Select(x => x.Amount).Single() - m.GetTotalPayment(paymentVM.Id);

            if (paymentVM.Amount > remaining)
            {
                ModelState.AddModelError("Over", "The field Amount can't greater than " + remaining.ToString("#,##0"));
            }

            if (ModelState.IsValid)
            {
                PaymentModels pay = new PaymentModels();
                pay.Id        = Guid.NewGuid();
                pay.No        = m.GetLastHexNo("payment").ToString("00000");
                pay.Timestamp = DateTime.Now;
                pay.Source_BankAccounts_Id = paymentVM.Source_BankAccounts_Id;
                pay.Target_BankAccounts_Id = paymentVM.Target_BankAccounts_Id;
                pay.Amount             = paymentVM.Amount;
                pay.ConfirmationNumber = paymentVM.ConfirmationNumber;
                pay.Notes = paymentVM.Notes;
                db.Payment.Add(pay);

                PaymentItemModels pi = new PaymentItemModels();
                pi.Id                = Guid.NewGuid();
                pi.Payments_Id       = pay.Id;
                pi.Transaction_RefId = paymentVM.Id;
                pi.Amount            = paymentVM.Amount;
                pi.Notes             = paymentVM.Notes;
                db.PaymentItem.Add(pi);

                db.SaveChanges();

                if (!paymentVM.hasPayment)
                {
                    using (var ctx = new HrContext())
                    {
                        int result = ctx.Database.ExecuteSqlCommand("UPDATE Payrolls SET hasPayment='True' WHERE Id='" + paymentVM.Id + "'");
                    }
                }

                return(RedirectToAction("Payroll"));
            }

            ViewBag.listTarget = new SelectList(db.BankAccount.Where(x => x.Active == true && x.Owner_RefId.Value == paymentVM.IdUser).OrderBy(x => x.Name).ToList(), "Id", "Name");
            ViewBag.listSource = new SelectList(db.BankAccount.Where(x => x.Active == true && x.Internal == true).OrderBy(x => x.Name).ToList(), "Id", "Name");
            return(View(paymentVM));
        }
コード例 #4
0
        public IHttpActionResult UpdatePayment(PaymentModels payment)
        {
            SqlDataReader SqlDtr;
            SqlCommand    SqlCmd;
            SqlConnection SqlCon1 = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["Servosms"]);

            payment.c = 0;
            string sql = "Update Payment_transaction set Ledger_ID_Dr = " + payment.Ledger_ID1 + ",Amount1 = " + payment.Amount1 + ",Ledger_ID_Cr = " + payment.By_ID1 + ",Amount2 = " + payment.Amount1 + ",Bank_Name='" + payment.Bank_name1 + "',Cheque_No='" + payment.Cheque_No1 + "',Cheque_date = CONVERT(datetime,'" + payment.dtDate + "', 103),Narration ='" + payment.narration1 + "',Entered_By = '" + payment.uid + "', Entry_Date= CONVERT(datetime,'" + payment.Entry_Date + "', 103) where Voucher_ID = '" + payment.VoucherId + "'";

            SqlCmd = new SqlCommand(sql, SqlCon1);

            SqlCon1.Open();
            SqlDtr = SqlCmd.ExecuteReader();
            SqlDtr.Close();
            payment.c = 1;
            object obj1 = null;

            if (payment.CheckCashMode.Equals(payment.DropBy))
            {
                dbobj.ExecProc(DbOperations_LATEST.OprType.Update, "ProUpdateAccountsLedger", ref obj1, "@Voucher_ID", payment.VoucherId, "@Ledger_ID", payment.Ledger_ID1, "@Amount", payment.Amount1, "@Type", "Dr", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
                dbobj.ExecProc(DbOperations_LATEST.OprType.Update, "ProUpdateAccountsLedger", ref obj1, "@Voucher_ID", payment.VoucherId, "@Ledger_ID", payment.By_ID1, "@Amount", payment.Amount1, "@Type", "Cr", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
            }
            else
            {
                sql    = "delete from CustomerLedgerTable where Particular = 'Voucher(" + payment.VoucherId + ")' and CustID='" + payment.OldCust_ID + "'";
                SqlCmd = new SqlCommand(sql, SqlCon1);
                SqlDtr = SqlCmd.ExecuteReader();
                SqlDtr.Close();

                sql    = "delete from AccountsLedgerTable where Particulars = 'Payment (" + payment.VoucherId + ")'";
                SqlCmd = new SqlCommand(sql, SqlCon1);
                SqlDtr = SqlCmd.ExecuteReader();
                SqlDtr.Close();

                dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProInsertAccountsLedger", ref obj1, "@Ledger_ID", payment.Ledger_ID1, "@Particulars", "Payment (" + payment.Vouch_ID + ")", "@Debit_Amount", payment.Amount1, "@Credit_Amount", "0.0", "@type", "Dr", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
                //dbobj.ExecProc(DBOperations.OprType.Insert, "ProInsertAccountsLedger", ref obj1, "@Ledger_ID", payment.By_ID1, "@Particulars", "Payment (" + payment.Vouch_ID + ")", "@Debit_Amount", "0.0", "@Credit_Amount", payment.Amount1, "@type", "Cr", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
                dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProCustomerLedgerEntry", ref obj1, "@Voucher_ID", payment.Vouch_ID, "@Ledger_ID", payment.Ledger_ID1, "@Amount", payment.Amount1, "@Type", "Dr.", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
                //dbobj.ExecProc(DBOperations.OprType.Insert, "ProCustomerLedgerEntry", ref obj1, "@Voucher_ID", payment.Vouch_ID, "@Ledger_ID", payment.By_ID1, "@Amount", payment.Amount1, "@Type", "Cr.", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
            }
            if (payment.Equals(0) || payment == null)
            {
                return(Content(HttpStatusCode.NotFound, "Payment Not Updated"));
            }
            return(Ok(payment));
        }
コード例 #5
0
        public IHttpActionResult SavePayment(PaymentModels payment)
        {
            SqlDataReader SqlDtr;
            string        Vouch_ID;
            string        By_ID = "";
            string        sql   = "Select Ledger_ID from Ledger_Master where Ledger_Name ='" + payment.By_Name + "'";

            SqlDtr = obj.GetRecordSet(sql);
            if (SqlDtr.Read())
            {
                By_ID = SqlDtr.GetValue(0).ToString();
            }
            SqlDtr.Close();

            sql    = "Select top 1(voucher_ID + 1)  from Payment_Transaction order by voucher_ID desc";
            SqlDtr = obj.GetRecordSet(sql);
            if (SqlDtr.Read())
            {
                Vouch_ID = SqlDtr.GetValue(0).ToString();
            }
            else
            {
                Vouch_ID = "50001";
            }
            SqlDtr.Close();
            payment.c = 0;
            sql       = "insert into payment_transaction values(" + Vouch_ID + ",'Payment'," + payment.Ledger_ID + "," + payment.Amount + "," + By_ID + "," + payment.Amount + ",'" + payment.Bank_name + "','" + payment.Cheque_No + "',CONVERT(datetime,'" + payment.dtDate + "', 103),'" + payment.narration + "','" + payment.uid + "', CONVERT(datetime,'" + payment.Entry_Date + "', 103))";
            SqlDtr    = obj.GetRecordSet(sql);
            payment.c = 1;
            object obj1 = null;

            dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProInsertAccountsLedger", ref obj1, "@Ledger_ID", payment.Ledger_ID, "@Particulars", "Payment (" + Vouch_ID + ")", "@Debit_Amount", payment.Amount, "@Credit_Amount", "0.0", "@type", "Dr", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
            dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProInsertAccountsLedger", ref obj1, "@Ledger_ID", By_ID, "@Particulars", "Payment (" + Vouch_ID + ")", "@Debit_Amount", "0.0", "@Credit_Amount", payment.Amount, "@type", "Cr", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
            dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProCustomerLedgerEntry", ref obj1, "@Voucher_ID", Vouch_ID, "@Ledger_ID", payment.Ledger_ID, "@Amount", payment.Amount, "@Type", "Dr.", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
            dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "ProCustomerLedgerEntry", ref obj1, "@Voucher_ID", Vouch_ID, "@Ledger_ID", By_ID, "@Amount", payment.Amount, "@Type", "Cr.", "@Invoice_Date", System.Convert.ToDateTime(payment.Entry_Date));
            if (payment.Equals(0) || payment == null)
            {
                return(Content(HttpStatusCode.NotFound, "Payment Not Saved"));
            }
            return(Ok(payment));
        }