예제 #1
0
        public async Task <ActionResult> EditDetailsPayment(int?id, int paymentid)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MaterialBuy materialBuy = await db.MaterialBuys.FindAsync(id);

            if (materialBuy == null)
            {
                return(HttpNotFound());
            }
            Payment payment = await db.Payments.FindAsync(paymentid);

            if (payment == null)
            {
                return(HttpNotFound());
            }
            var materialBuyPayment = new MaterialBuyPaymentData();

            materialBuyPayment.MaterialBuy = materialBuy;
            materialBuyPayment.Payment     = payment;

            materialBuyPayment.MaterialBuy.Payments = materialBuyPayment.MaterialBuy.Payments.OrderBy(p => p.Date).ToList();


            return(View(materialBuyPayment));
        }
예제 #2
0
        public async Task <ActionResult> EditAddPayment(MaterialBuyPaymentData materialBuyPaymentData)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                //                db.Entry(materialBuyData).State = EntityState.Modified;
                MaterialBuy materialBuy = db.MaterialBuys.FirstOrDefault(m => m.ID == materialBuyPaymentData.MaterialBuy.ID);

                materialBuyPaymentData.Payment.EmployeeID = Convert.ToInt32(Session["LoginUserEmployeeID"]);
                materialBuyPaymentData.Payment.Employee   = db.Employees.FirstOrDefault(e => e.ID == materialBuyPaymentData.Payment.EmployeeID);
                materialBuyPaymentData.Payment.CompanyID  = materialBuyPaymentData.MaterialBuy.CompanyID;
                materialBuyPaymentData.Payment.ProjectID  = materialBuyPaymentData.MaterialBuy.ProjectID;

                db.Payments.Add(materialBuyPaymentData.Payment);
                materialBuy.Payments.Add(materialBuyPaymentData.Payment);

                await db.SaveChangesAsync();

                return(RedirectToAction("EditAddPayment", new { id = materialBuyPaymentData.MaterialBuy.ID }));
            }
            return(View(materialBuyPaymentData));
        }
예제 #3
0
        public async Task <ActionResult> EditEditPayment(int id, int paymentid, MaterialBuyPaymentData materialBuyPaymentData)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                //                db.Entry(materialBuyData).State = EntityState.Modified;
                MaterialBuy materialBuy = db.MaterialBuys.FirstOrDefault(m => m.ID == materialBuyPaymentData.MaterialBuy.ID);
                Payment     payment     = await db.Payments.FindAsync(paymentid);

                payment.Date         = materialBuyPaymentData.Payment.Date;
                payment.Type         = materialBuyPaymentData.Payment.Type;
                payment.Amount       = materialBuyPaymentData.Payment.Amount;
                payment.Currency     = materialBuyPaymentData.Payment.Currency;
                payment.AmountString = materialBuyPaymentData.Payment.AmountString;
                payment.CompanyID    = materialBuyPaymentData.MaterialBuy.CompanyID;
                payment.ProjectID    = materialBuyPaymentData.MaterialBuy.ProjectID;

                if (payment.NoteVn != null && !payment.NoteVn.Equals(materialBuyPaymentData.Payment.NoteVn))
                {
                    payment.NoteVn    = materialBuyPaymentData.Payment.NoteVn;
                    payment.Translate = false;
                }
                if (materialBuyPaymentData.Payment.NoteVn != null)
                {
                    payment.NoteVn    = materialBuyPaymentData.Payment.NoteVn;
                    payment.Translate = false;
                }
                if (payment.NoteVn == null || payment.NoteVn.Length <= 0)
                {
                    payment.Translate = true;
                }

                await db.SaveChangesAsync();

                return(RedirectToAction("EditAddPayment", new { id = materialBuyPaymentData.MaterialBuy.ID }));
            }
            return(View(materialBuyPaymentData));
        }
예제 #4
0
        public async Task <ActionResult> EditAddPayment(int?id)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MaterialBuy materialBuy = await db.MaterialBuys.FindAsync(id);

            if (materialBuy == null)
            {
                return(HttpNotFound());
            }
            var materialBuyPayment = new MaterialBuyPaymentData();

            materialBuyPayment.MaterialBuy = materialBuy;

            return(View(materialBuyPayment));
        }