コード例 #1
0
        // GET: InvReceipts/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InvReceipt    invReceipt    = db.InvReceipts.Find(id);
            InvReceiptDto invreceiptdto = new InvReceiptDto()
            {
                Description  = invReceipt.Description,
                Id           = invReceipt.Id,
                ObjectState  = (int)ObjectState.Unchanged,
                ReceiptDate  = invReceipt.ReceiptDate,
                ReceiptNo    = invReceipt.ReceiptNo,
                ReceivedById = invReceipt.ReceivedBy,
                VendorId     = invReceipt.VendorId,
                listUser     = db.AspNetUsers.Select(x => new UserDto {
                    Email = x.Email, Id = x.Id
                }).ToList(),
                listVendor = db.Vendors.Select(x => new VendorDto()
                {
                    Id = x.Id, Name = x.Name
                }).ToList(),
                listDetail        = GetDetails(invReceipt.Id),
                listReceivedPlace = RecievedPlaceDto.ConvertEnum(),
                ReceivedPlaceId   = (int)Enum.Parse(typeof(RecievePlace), invReceipt.ReceivedPlace)
            };

            if (invReceipt == null)
            {
                return(HttpNotFound());
            }
            return(View(invreceiptdto));
        }
コード例 #2
0
 private void BtnAddPayment_Click(object sender, EventArgs e)
 {
     try
     {
         receiptController.FillReceipt(orderNumber, double.Parse(TxtAmount.Text), DateOrderDate.Value.ToString("yyyy-MM-dd"), orderType, custID);
         receiptController.WriteReceipt(this);
         if (orderType == "LENSE")
         {
             technovisionDataSetTableAdapters.contactlenseTableAdapter t = new technovisionDataSetTableAdapters.contactlenseTableAdapter();
             t.UpdateBalanceByOrderNumber(double.Parse(LblDueAmount.Text) - double.Parse(TxtAmount.Text), orderNumber);
             t.Dispose();
             CommonFunctions.ShowSuccess(this, "New Payment Added To " + LblOrderNo.Text);
             CommonFunctions.WriteUserLog(Session.Username, "New Payment Added To " + LblOrderNo.Text);
             this.receiptTableAdapter.Fill(this.technovisionDataSet.receipt);
             receiptBindingSource.Filter = "OrderNumber ='" + orderNumber + "' AND OrderType = '" + orderType + "' AND Branch = " + Session.BranchId;
             InvReceiptContactLense rpt = new InvReceiptContactLense();
             rpt.RecordSelectionFormula = "{receipt1.ReceiptNumber} ='" + LblReceiptNo.Text + "'";
             rpt.PrintToPrinter(2, false, 1, 1);
             new UI_REPORT_VIEWER(rpt).Show();
         }
         if (orderType == "SPEC")
         {
             technovisionDataSetTableAdapters.spectaclesTableAdapter t = new technovisionDataSetTableAdapters.spectaclesTableAdapter();
             t.UpdateBalanceByOrderNumber(double.Parse(LblDueAmount.Text) - double.Parse(TxtAmount.Text), orderNumber);
             t.Dispose();
             CommonFunctions.ShowSuccess(this, "New Payment Added To " + LblOrderNo.Text);
             CommonFunctions.WriteUserLog(Session.Username, "New Payment Added To " + LblOrderNo.Text);
             this.receiptTableAdapter.Fill(this.technovisionDataSet.receipt);
             receiptBindingSource.Filter = "OrderNumber ='" + orderNumber + "' AND OrderType = '" + orderType + "' AND Branch = " + Session.BranchId;
             InvReceipt rpt = new InvReceipt();
             rpt.RecordSelectionFormula = "{receipt1.ReceiptNumber} ='" + LblReceiptNo.Text + "'";
             rpt.PrintToPrinter(2, false, 1, 1);
             new UI_REPORT_VIEWER(rpt).Show();
         }
     }
     catch (Exception ex)
     {
         CommonFunctions.ShowError(this, ex.Message.ToString());
         CommonFunctions.WriteToErrorLog(ex.Message.ToString());
     }
 }
コード例 #3
0
        private void BtnPrintReceipt_Click(object sender, EventArgs e)
        {
            string OrderType     = GridPayment.SelectedRows[0].Cells[4].Value.ToString();
            string ReceiptNumber = GridPayment.SelectedRows[0].Cells[2].Value.ToString();

            if (OrderType == "LENSE")
            {
                InvReceiptContactLense rpt = new InvReceiptContactLense();
                rpt.RecordSelectionFormula = "{receipt1.ReceiptNumber} ='" + ReceiptNumber + "'";
                rpt.PrintToPrinter(1, false, 1, 1);
                new UI_REPORT_VIEWER(rpt).Show();
                rpt.PrintToPrinter(1, false, 1, 1);
            }
            else if (OrderType == "SPEC")
            {
                InvReceipt rpt = new InvReceipt();
                rpt.RecordSelectionFormula = "{receipt1.ReceiptNumber} ='" + ReceiptNumber + "'";
                rpt.PrintToPrinter(1, false, 1, 1);
                new UI_REPORT_VIEWER(rpt).Show();
                rpt.PrintToPrinter(1, false, 1, 1);
            }
        }
コード例 #4
0
        public async Task <JsonResult> SaveAsync(InvReceiptDto vm)
        {
            try
            {
                if (vm.listDetailToDelete.Count() > 0)
                {
                    foreach (var item in vm.listDetailToDelete)
                    {
                        var objdelete = db.InvReceiptDetails.Find(item);
                        if (objdelete != null)
                        {
                            db.Entry(objdelete).State = EntityState.Deleted;
                            await db.SaveChangesAsync();
                        }
                    }
                }
                var objsave = new InvReceipt()
                {
                    Id            = vm.Id,
                    Description   = vm.Description,
                    ReceiptDate   = vm.ReceiptDate,
                    ReceiptNo     = vm.ReceiptNo,
                    ReceivedBy    = vm.ReceivedById,
                    VendorId      = vm.VendorId,
                    ReceivedPlace = ((RecievePlace)vm.ReceivedPlaceId).ToString()
                };
                if (objsave.Id > 0 && vm.ObjectState != (int)ObjectState.Deleted)
                {
                    vm.ObjectState = (int)ObjectState.Modified;
                }
                if (objsave.Id <= 0 && vm.ObjectState != (int)ObjectState.Deleted)
                {
                    vm.ObjectState = (int)ObjectState.Added;
                }
                switch (vm.ObjectState)
                {
                case (int)ObjectState.Added:
                    db.InvReceipts.Add(objsave);
                    await db.SaveChangesAsync();

                    break;

                case (int)ObjectState.Modified:
                    db.Entry(objsave).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    break;

                case (int)ObjectState.Deleted:
                    var returndetails = db.InvReceiptDetails.Where(x => x.InvReceiptId == objsave.Id).ToList();
                    foreach (var item in returndetails)
                    {
                        var invReturndetail = await db.InvReceiptDetails.FindAsync(item.Id);

                        db.Entry(invReturndetail).State = EntityState.Deleted;
                        db.SaveChanges();
                    }
                    db.Entry(objsave).State = EntityState.Deleted;
                    await db.SaveChangesAsync();

                    break;
                }
                vm.Id         = objsave.Id;
                vm.listDetail = await SaveDetailAsync(vm);

                var result = new { result = vm };
                return(Json(result));
            }
            catch (Exception ex)
            {
                return(Json(null));
            }
        }