예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblReceipt tblReceipt = db.tblReceipt.Find(id);

            db.tblReceipt.Remove(tblReceipt);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblReceipt tblReceipt = db.tblReceipt.Find(id);

            db.tblReceipt.Remove(tblReceipt);
            db.SaveChanges();
            TempData["Success"] = "Deleted Successfully";
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Id,Start_no,End_no,Date,Current_Recipt,Status")] tblReceipt tblReceipt)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblReceipt).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblReceipt));
 }
예제 #4
0
        public ActionResult Create([Bind(Include = "Id,Start_no,End_no,Date,Current_Recipt,Status")] tblReceipt tblReceipt)
        {
            if (ModelState.IsValid)
            {
                db.tblReceipt.Add(tblReceipt);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblReceipt));
        }
예제 #5
0
        // GET: Auth/Receipt/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblReceipt tblReceipt = db.tblReceipt.Find(id);

            if (tblReceipt == null)
            {
                return(HttpNotFound());
            }
            return(View(tblReceipt));
        }
예제 #6
0
        public multiReceiptViewForm(tblClaimant MyClaimant, DateTime Start, DateTime End, tblReceipt MyReceipt, BindingList<tblPayin> MyPayments)
        {
            InitializeComponent();
            this.myClaimant = MyClaimant;
            startDate = Start;
            endDate = End;
            myUnPaidInvoices.AllowEdit = true;
            myUnPaidInvoices.AllowNew = true;
            myUnPaidInvoices.AllowRemove = true;
            myPayments.ListChanged += new ListChangedEventHandler(myPayments_ListChanged);

            myReceipt = MyReceipt;
            foreach (var p in MyPayments)
            {
                myPayments.Add(p);
            }

            updateForm();
            multipleReceiptGridControl.DataSource = myUnPaidInvoices;
            updateClaimantDetails();
        }
        public ActionResult UpdateReceipt(ReceiptViewModel oReceiptViewModel)
        {
            try
            {
                int userId = ((tblUser)Session["Admin"]).UserId;

                // updates receipt details
                tblReceipt receipt = db.tblReceipts.Where(m => m.ReceiptId == oReceiptViewModel.ReceiptId).FirstOrDefault();

                receipt.SupplierName    = oReceiptViewModel.SupplierName;
                receipt.BillingDate     = oReceiptViewModel.BillingDate;
                receipt.LocationName    = oReceiptViewModel.LocationName;
                receipt.Note            = oReceiptViewModel.Note;
                receipt.TotalBillAmount = oReceiptViewModel.TotalBillAmount;

                db.Entry(receipt).State = EntityState.Modified;
                db.SaveChanges();

                // updates receipt items
                if (oReceiptViewModel.ListOfReceiptItem != null)
                {
                    foreach (var item in oReceiptViewModel.ListOfReceiptItem)
                    {
                        tblItem otblItem = db.tblItems.Where(m => m.ItemId == item.ItemId && m.ReceiptId == oReceiptViewModel.ReceiptId).FirstOrDefault();

                        otblItem.ItemName = item.ItemName;
                        otblItem.Quantity = item.Quantity;
                        otblItem.Price    = item.Price;

                        db.Entry(otblItem).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }

                List <tblUserReceiptTag> userTags = (from d in db.tblUserReceiptTags
                                                     where d.ReceiptId == oReceiptViewModel.ReceiptId
                                                     select d).ToList();

                // if user tags does not have any tags then add all items
                if (userTags.Count == 0)
                {
                    if (oReceiptViewModel.TagIds != null)
                    {
                        foreach (int tid in oReceiptViewModel.TagIds)
                        {
                            tblUserReceiptTag receiptTag = new tblUserReceiptTag();

                            receiptTag.TagsId    = tid;
                            receiptTag.ReceiptId = oReceiptViewModel.ReceiptId;
                            receiptTag.UserId    = userId;

                            db.tblUserReceiptTags.Add(receiptTag);
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    // if tagids dont have any tag then delete all tags
                    if (oReceiptViewModel.TagIds == null)
                    {
                        foreach (tblUserReceiptTag usertag in userTags)
                        {
                            db.tblUserReceiptTags.Remove(usertag);
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        foreach (tblUserReceiptTag usertag in userTags)
                        {
                            bool isAvailable = oReceiptViewModel.TagIds.Contains(usertag.TagsId.Value);

                            if (isAvailable == false)
                            {
                                tblUserReceiptTag receiptTag = (from y in db.tblUserReceiptTags
                                                                where y.TagsId == usertag.TagsId
                                                                select y).FirstOrDefault();

                                db.tblUserReceiptTags.Remove(receiptTag);
                                db.SaveChanges();
                            }
                        }

                        foreach (int tagId in oReceiptViewModel.TagIds)
                        {
                            var checkIsAvailable = userTags.Where(m => m.TagsId == tagId).FirstOrDefault();

                            // if not availble
                            if (checkIsAvailable == null)
                            {
                                tblUserReceiptTag receiptTag = new tblUserReceiptTag();

                                receiptTag.TagsId    = tagId;
                                receiptTag.ReceiptId = oReceiptViewModel.ReceiptId;
                                receiptTag.UserId    = userId;

                                db.tblUserReceiptTags.Add(receiptTag);
                                db.SaveChanges();
                            }
                        }
                    }
                }

                TempData["Success"] = "Receipt updated successfully.";
                return(RedirectToAction("ReceiptsList", "Receipts", new { page = Convert.ToInt32(Session["page"]), search = Session["Search"], area = "Admin" }));
            }
            catch (Exception ex)
            {
                GlobalVariable.objWriteLog.PrintMessage(Server.MapPath("~/ErrorLog/"), ex.Message);
                throw ex;
            }
        }
예제 #8
0
        void retrieveInvoiceDetails(tblInvoice MyInvoice)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                myInvoice = MyInvoice;

                var Lines = myConnection.getInvoiceLines(myInvoice.InvoiceNo).ToList();
                foreach (var line in Lines)
                {
                    AnonInvoiceLines newLine = new AnonInvoiceLines();
                    newLine.Fee = line.Fee;
                    newLine.GST = line.GST;
                    newLine.RateID = line.RateID;
                    newLine.PatientName = line.Patient;
                    newLine.SessionDate = line.Date;
                    newLine.ItemNo = line.ItemNo;
                    newLine.PatientID = line.PatientID;

                    myLines.Add(newLine);
                }

                myTransaction = myConnection.tblTransactions.
                    Where(transaction => (transaction.InvoiceNo == MyInvoice.InvoiceNo) && (transaction.TranType == "I")).FirstOrDefault();
                myClaimant = myConnection.tblClaimants.Where(claimant => claimant.ClaimantID == myTransaction.ClaimantID).FirstOrDefault();
                myPhysio = myConnection.tblPhysios.Where(physio => physio.PhysioID == myTransaction.PhysioID).FirstOrDefault();
                var myReceiptLines = myConnection.getReceiptsOfSingleInvoice(myInvoice.InvoiceNo).ToList();
                var myReceiptDetails = myConnection.getReceiptDetailsOfSingleInvoice(myInvoice.InvoiceNo).ToList();

                foreach (var line in myReceiptLines)
                {
                    tblInvoiceReceipt myLine = new tblInvoiceReceipt();
                    myLine.InvoiceNo = line.InvoiceNo;
                    myLine.InvoiceReceiptID = line.InvoiceNo;
                    myLine.InvRecAmnt = line.InvRecAmnt;
                    myLine.ReceiptNo = line.ReceiptNo;
                    myReceiptAmounts.Add(myLine);
                }

                foreach (var line in myReceiptDetails)
                {
                    tblReceipt myLine = new tblReceipt();
                    myLine.ReceiptNo = line.ReceiptNo;
                    myLine.ReceiptDate = line.ReceiptDate;
                    myLine.ReceiptComments = line.ReceiptComments;
                    myLine.ReceiptAmnt = line.ReceiptAmnt;
                    myLine.IsMulti = line.IsMulti;
                    myLine.ReceiptCancelled = line.ReceiptCancelled;
                    myReceipts.Add(myLine);
                }

                this.claimantBillingAddressMemoEdit.Text = myClaimant.FirstNames + Environment.NewLine + myClaimant.LastName + Environment.NewLine
                    + myClaimant.Address1 + Environment.NewLine + myClaimant.Address2 + Environment.NewLine + myClaimant.Address3 + Environment.NewLine;

                this.invoiceDateEdit.DateTime = myTransaction.TranDate.Value;
                this.commentsMemoExEdit.Text = myInvoice.InvoiceComments;

                if (myInvoice.InvoiceCancelled.GetValueOrDefault(false) != true)
                {
                    makeInvoiceOfficial();
                }
                else
                {
                    cancelInvoice();
                }

                this.physioLookUp.EditValue = myPhysio.PhysioID;

                Cursor.Current = Cursors.Default;
            }
            catch (Exception)
            {
                MessageBox.Show("Can not display invoice. Data is corrupt.");
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }
        }