Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            saleproduct saleProduct = db.saleproducts.Find(id);

            db.saleproducts.Remove(saleProduct);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
        public winSaleEdit(HCSController controller,saleproduct productSold)
        {
            InitializeComponent();

            CONTROLLER = controller;

            soldProduct = productSold;
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "ID,Name,ShortName,Type,Size,Color,Price,Description,ProductCategoryID,BrandID,UnitID,Status,ImagePath,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy")] saleproduct saleProduct)
 {
     if (ModelState.IsValid)
     {
         db.Entry(saleProduct).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BrandID           = new SelectList(db.brandsmasters, "ID", "BrandName", saleProduct.BrandID);
     ViewBag.ProductCategoryID = new SelectList(db.productcategories, "ID", "Name", saleProduct.ProductCategoryID);
     ViewBag.UnitID            = new SelectList(db.units, "ID", "Name", saleProduct.UnitID);
     return(View(saleProduct));
 }
Example #4
0
        // GET: SaleProducts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            saleproduct saleProduct = db.saleproducts.Find(id);

            if (saleProduct == null)
            {
                return(HttpNotFound());
            }
            return(View(saleProduct));
        }
 private void winSaleProduct_Loaded(object sender, RoutedEventArgs e)
 {
     if (CONTROLLER == null)
     {
         CONTROLLER = new HCSController();
     }
     saleProduct = new saleproduct() { date = DateTime.Now, isenglishvisible = CONTROLLER.ISENGLISHVISIBLE, isurduvisible = CONTROLLER.ISURDUVISIBLE };
     bindProducts();
     bindFeedMillUsers();
     bindPurchaserTypes();
     bindSalType();
     this.grdSaleProduct.DataContext = CONTROLLER.SALEPRODUCT;
     this.grdModel.DataContext = CONTROLLER.SALEPRODUCT;
 }
Example #6
0
        // GET: SaleProducts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            saleproduct saleProduct = db.saleproducts.Find(id);

            if (saleProduct == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BrandID           = new SelectList(db.brandsmasters, "ID", "BrandName", saleProduct.BrandID);
            ViewBag.ProductCategoryID = new SelectList(db.productcategories, "ID", "Name", saleProduct.ProductCategoryID);
            ViewBag.UnitID            = new SelectList(db.units, "ID", "Name", saleProduct.UnitID);
            return(View(saleProduct));
        }
Example #7
0
 public ActionResult Add(saleproduct sp)
 {
     if (Session["cart"] == null)
     {
         List <saleproduct> li = new List <saleproduct>();
         li.Add(sp);
         Session["cart"]  = li;
         ViewBag.cart     = li.Count();
         Session["count"] = 1;
     }
     else
     {
         List <saleproduct> li = (List <saleproduct>)Session["cart"];
         li.Add(sp);
         Session["cart"]  = li;
         ViewBag.cart     = li.Count();
         Session["count"] = Convert.ToInt32(Session["count"]) + 1;
     }
     return(RedirectToAction("NewOrder", "Orders"));
 }
Example #8
0
        private void winSaleEdit_Loaded(object sender, RoutedEventArgs e)
        {
            if(CONTROLLER==null)
            {
                CONTROLLER = new HCSController();

            }
            if(soldProduct==null )
            {
                soldProduct = new saleproduct() { date = DateTime.Now, isenglishvisible = CONTROLLER.ISENGLISHVISIBLE, isurduvisible = CONTROLLER.ISURDUVISIBLE };

            }

            bindProducts();
            bindFeedMillUsers();
            this.grdSaleProduct.DataContext = soldProduct;
            this.grdModel.DataContext = soldProduct;


        }
Example #9
0
        public ActionResult Create(saleproduct saleProduct)
        {
            if (ModelState.IsValid)
            {
                var file = Request.Files["ImageUpload"];
                if (file != null && file.ContentLength > 0)
                {
                    var uploadDir = "~/assets/ProductImages";
                    var imagePath = Path.Combine(Server.MapPath(uploadDir), file.FileName);
                    var imageUrl  = Path.Combine(uploadDir, file.FileName);
                    file.SaveAs(imagePath);
                    saleProduct.ImagePath = imageUrl;
                }

                db.saleproducts.Add(saleProduct);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BrandID           = new SelectList(db.brandsmasters, "ID", "BrandName", saleProduct.BrandID);
            ViewBag.ProductCategoryID = new SelectList(db.productcategories, "ID", "Name", saleProduct.ProductCategoryID);
            ViewBag.UnitID            = new SelectList(db.units, "ID", "Name", saleProduct.UnitID);
            return(View(saleProduct));
        }
Example #10
0
        public void saveFeedMillPayment(saleproduct payment)
        {
            payment.date = DateTime.Now;
            FeedMillTotalRecievable feedMillPayment = dbContext.FeedMillTotalRecievables.Where(p => p.feedmillid == payment.feedmillid).FirstOrDefault();
            feedMillPayment.totalPriceRecievable = payment.totalpricerecieveable;
            feedMillPayment.totalPayable += payment.totalpayable;
            payment.totalpayable = feedMillPayment.totalPayable;
            var entry = dbContext.Entry<FeedMillTotalRecievable>(feedMillPayment);
            if (entry.State.Equals(EntityState.Detached))
            {
                dbContext.FeedMillTotalRecievables.Attach(feedMillPayment);
            }
            entry.State = EntityState.Modified;
 
            dbContext.saleproducts.Add(payment);
            dbContext.SaveChanges();

           


        }
 public winFeedMillReportViewer(saleproduct product, bool isurduvisible)
 {
     InitializeComponent();
     m_isurduvisible = isurduvisible;
     productSold = product;
 }
        private void btnRecieveAmount_Click(object sender, RoutedEventArgs e)
        {
            if(!string.IsNullOrEmpty(tbAmountRecieved.Text))
            {
                decimal amountReceived = Convert.ToDecimal(tbAmountRecieved.Text);

                SaleProduct = new saleproduct();
                SaleProduct.feedmillid = feedMillId;
                SaleProduct.amountrecieved = amountReceived;
                if (amountReceived > totalRecievable)
                {
                    SaleProduct.totalpricerecieveable = 0;
                    SaleProduct.totalpayable = amountReceived - totalRecievable;
                }
                else
                {
                    SaleProduct.totalpricerecieveable = totalRecievable - amountReceived;
                    SaleProduct.totalpayable = 0;

                }
                CONTROLLER.saveFeedMillPayment(SaleProduct);
                FEEDMILLHISTORY.Add(SaleProduct);
                MessageBox.Show("Amount Paid Saved Successfully!");
                RefreshUsers();
                setTotalRecievable();                
            
            }

        }
Example #13
0
        public void saveProductSold(saleproduct productSold)
        {
            saleDb.saleproducts.Add(productSold);
            saleDb.SaveChanges();

        }
Example #14
0
        private void removeSale(saleproduct removeProduct)
        {
            dbContext.saleproducts.Remove(removeProduct);
            dbContext.SaveChanges();


        }
Example #15
0
        public void updateProductSold(saleproduct productSold)
        {
            removeSale(productSold);
            FeedMillTotalRecievable totalRecievable = dbContext.FeedMillTotalRecievables.Where(p => p.feedmillid == productSold.feedmillid).FirstOrDefault();
            if (totalRecievable != null)
            {
                if (totalRecievable.totalPayable > 0)
                {
                    if (productSold.recievableprice > (totalRecievable.totalPayable + OLDRECEIVABLEPRICE))
                    {
                        totalRecievable.totalPriceRecievable = productSold.recievableprice - (totalRecievable.totalPayable + OLDRECEIVABLEPRICE);
                        productSold.totalpricerecieveable = totalRecievable.totalPriceRecievable;
                        totalRecievable.totalPayable = 0;
                        productSold.totalpayable = 0;
                    }
                    else
                    {

                        totalRecievable.totalPayable = totalRecievable.totalPayable - productSold.recievableprice + OLDRECEIVABLEPRICE;
                        productSold.totalpayable = totalRecievable.totalPayable;
                        totalRecievable.totalPriceRecievable = 0;
                        productSold.totalpricerecieveable = 0;
                    }
                }

                else
                {
                    if (OLDRECEIVABLEPRICE > (totalRecievable.totalPriceRecievable + productSold.recievableprice))
                    {
                        totalRecievable.totalPayable = OLDRECEIVABLEPRICE - (totalRecievable.totalPriceRecievable + productSold.recievableprice);
                        productSold.totalpayable = totalRecievable.totalPayable;
                        totalRecievable.totalPriceRecievable = 0;
                        productSold.totalpricerecieveable = 0;

                    }
                    else
                    {

                        productSold.totalpricerecieveable = totalRecievable.totalPriceRecievable + productSold.recievableprice - OLDRECEIVABLEPRICE;
                        totalRecievable.totalPriceRecievable = productSold.totalpricerecieveable;
                        productSold.totalpayable = 0;
                        totalRecievable.totalPayable = 0;
                    }
                }
                var entry = dbContext.Entry<FeedMillTotalRecievable>(totalRecievable);
                if (entry.State.Equals(EntityState.Detached))
                {
                    dbContext.FeedMillTotalRecievables.Attach(totalRecievable);
                }
                entry.State = EntityState.Modified;


            }

            dbContext.saleproducts.Add(productSold);
            dbContext.SaveChanges();

        }
Example #16
0
        public void saveProductSold(saleproduct productSold)
        {
            try
            {

           
            #region commented code save to feedmilltotla receivaable
            /*
            FeedMillTotalRecievable totalRecievable = dbContext.FeedMillTotalRecievables.Where(p => p.feedmillid == productSold.feedmillid).FirstOrDefault();
            if (totalRecievable != null)
            {
                if(totalRecievable.totalPayable>0)
                {
                    if(totalRecievable.totalPayable>=productSold.recievableprice)
                    {
                        totalRecievable.totalPayable -= productSold.recievableprice;
                        productSold.totalpayable = totalRecievable.totalPayable;
                        totalRecievable.totalPriceRecievable = 0;
                        productSold.totalpricerecieveable = 0;

                    }
                    else
                    {

                        productSold.totalpricerecieveable = productSold.recievableprice - totalRecievable.totalPayable;
                        totalRecievable.totalPriceRecievable = productSold.totalpricerecieveable;

                        productSold.totalpayable = 0;
                        totalRecievable.totalPayable = 0;
                    
                    }

                }
                else
                { 
                productSold.totalpricerecieveable = totalRecievable.totalPriceRecievable + productSold.recievableprice;
                totalRecievable.totalPriceRecievable = productSold.totalpricerecieveable;
                }
                var entry = dbContext.Entry<FeedMillTotalRecievable>(totalRecievable);
                if (entry.State.Equals(EntityState.Detached))
                {
                    dbContext.FeedMillTotalRecievables.Attach(totalRecievable);
                }
                entry.State = EntityState.Modified;


            }

            else
            {
                totalRecievable = new FeedMillTotalRecievable();
                productSold.totalpricerecieveable = productSold.recievableprice;
                totalRecievable.feedmillid = productSold.feedmillid;
                totalRecievable.totalPriceRecievable = productSold.totalpricerecieveable;

                dbContext.FeedMillTotalRecievables.Add(totalRecievable);

            }
            */
#endregion
            //entry in product sold
            dbContext.saleproducts.Add(productSold);
                dbContext.SaveChanges();
            #region Khata
            var result = from n in dbContext.Khatas where n.bpid == productSold.purchaserid select n;
            //entry in khata table for purchaser
            Khata kh = new Khata()
            {
                entrycode = "p",//indicates purchaser record
                purchaseproductid =0,
                saleproductid = productSold.seqid,
                activitycode = ActivityType.Sale.GetStringValue(),
                date = System.DateTime.Now,
                productid = productSold.productid,
                bpid = productSold.purchaserid,
                //sellerid = productSold.sellerid,
                sellertypecode = productSold.sellertypecde,
                payable_naam = productSold.price,
                receivable_jama = 0,
                purchasertypecode = productSold.purchasertypecde,
                totalpayable_naam = (result != null && result.Count() > 0) ? result.Sum(p => p.payable_naam) + productSold.price : productSold.price,
                totalreceivable_jama = (result != null && result.Count() > 0) ? result.Sum(p => p.receivable_jama) : 0
            };
            dbContext.Khatas.Add(kh);

            //now putting entries in KHATA table for seller(e.g Kissaan) khata
            result = from n in dbContext.Khatas where n.bpid == productSold.sellerid select n;
            kh = new Khata()
            {
                entrycode = "s",//indicates purchaser record
                purchaseproductid = 0,
                saleproductid = productSold.seqid,
                activitycode = ActivityType.Sale.GetStringValue(),
                date = System.DateTime.Now,
                productid = productSold.productid,
                //purchaserid = productSold.purchaserid,
                bpid = productSold.sellerid,
                sellertypecode = productSold.sellertypecde,
                payable_naam = 0,
                receivable_jama = productSold.recievableprice,
                totalpayable_naam = (result != null && result.Count() > 0) ? result.Sum(p => p.payable_naam) : 0,
                totalreceivable_jama = (result != null && result.Count() > 0) ? result.Sum(p => p.receivable_jama) + productSold.recievableprice : productSold.recievableprice,
                purchasertypecode = productSold.purchasertypecde
            };
            dbContext.Khatas.Add(kh);

            #endregion
            //-------------------------------------------------------
            //Now adding in otherKhata table for labor commission etc.
            //-------------------------------------------------------
            #region Other Khata

            //here collecting information about labour khata so as to calculate previous values of naam and jama
            string khatatypecode = KhataType.Labour.GetStringValue();
            var resultOtherKhata = from n in dbContext.OtherKhatas where n.khatatypecde == khatatypecode select n;//activity code indicates it is khata agains purchase

            OtherKhata ok = new OtherKhata()
                {
                    activitycode = ActivityType.Sale.GetStringValue(),
                    khatatypecde = KhataType.Labour.GetStringValue(),
                    date = System.DateTime.Now,
                    receivable_jama = productSold.labour,
                    payable_naam = 0,
                    productname = productSold.productname,
                    weight = productSold.weight,
                    purchaserid = productSold.purchaserid,
                    sellerid = productSold.sellerid,
                    sellertypecode = productSold.sellertypecde,
                    purchasertypecode = productSold.purchasertypecde,
                    totalpayable_naam = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.payable_naam) + productSold.price : productSold.price,
                    totalreceivable_jama = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.receivable_jama) : 0
                };
                dbContext.OtherKhatas.Add(ok);


                //here collecting information about labour khata so as to calculate previous values of naam and jama
                khatatypecode = KhataType.Commission.GetStringValue();
                resultOtherKhata = from n in dbContext.OtherKhatas where n.khatatypecde == khatatypecode select n;//activity code indicates it is khata agains purchase
                ok = new OtherKhata()
                {
                    activitycode = ActivityType.Sale.GetStringValue(),
                    khatatypecde = KhataType.Commission.GetStringValue(),
                    date = System.DateTime.Now,
                    receivable_jama = productSold.commissionamount,
                    payable_naam = 0,
                    productname = productSold.productname,
                    weight = productSold.weight,
                    purchaserid = productSold.purchaserid,
                    sellerid = productSold.sellerid,
                    sellertypecode = productSold.sellertypecde,
                    purchasertypecode = productSold.purchasertypecde,
                    totalpayable_naam = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.payable_naam) + productSold.price : productSold.price,
                    totalreceivable_jama = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.receivable_jama) : 0
                };
                dbContext.OtherKhatas.Add(ok);
                //here collecting information about labour khata so as to calculate previous values of naam and jama
                khatatypecode = KhataType.Bardana.GetStringValue();
                resultOtherKhata = from n in dbContext.OtherKhatas where n.khatatypecde == khatatypecode select n;//activity code indicates it is khata agains purchase

                ok = new OtherKhata()
                {
                    activitycode = ActivityType.Sale.GetStringValue(),
                    khatatypecde = KhataType.Bardana.GetStringValue(),
                    date = System.DateTime.Now,
                    receivable_jama = productSold.bardana,
                    payable_naam = 0,
                    productname = productSold.productname,
                    weight = productSold.weight,
                    purchaserid = productSold.purchaserid,
                    sellerid = productSold.sellerid,
                    sellertypecode = productSold.sellertypecde,
                    purchasertypecode = productSold.purchasertypecde,
                    totalpayable_naam = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.payable_naam) + productSold.price : productSold.price,
                    totalreceivable_jama = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.receivable_jama) : 0
                };
                dbContext.OtherKhatas.Add(ok);
                //here collecting information about labour khata so as to calculate previous values of naam and jama
                khatatypecode = KhataType.Fee.GetStringValue();
                resultOtherKhata = from n in dbContext.OtherKhatas where n.khatatypecde == khatatypecode select n;//activity code indicates it is khata agains purchase

                ok = new OtherKhata()
                {
                    activitycode = ActivityType.Sale.GetStringValue(),
                    khatatypecde = KhataType.Fee.GetStringValue(),
                    date = System.DateTime.Now,
                    receivable_jama = productSold.fee,
                    payable_naam = 0,
                    productname = productSold.productname,
                    weight = productSold.weight,
                    purchaserid = productSold.purchaserid,
                    sellerid = productSold.sellerid,
                    sellertypecode = productSold.sellertypecde,
                    purchasertypecode = productSold.purchasertypecde,
                    totalpayable_naam = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.payable_naam) + productSold.price : productSold.price,
                    totalreceivable_jama = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.receivable_jama) : 0
                };
                dbContext.OtherKhatas.Add(ok);
                //here collecting information about labour khata so as to calculate previous values of naam and jama
                khatatypecode = KhataType.Munshiyana.GetStringValue();
                resultOtherKhata = from n in dbContext.OtherKhatas where n.khatatypecde == khatatypecode select n;//activity code indicates it is khata agains purchase

                ok = new OtherKhata()
                {
                    activitycode = ActivityType.Sale.GetStringValue(),
                    khatatypecde = KhataType.Munshiyana.GetStringValue(),
                    date = System.DateTime.Now,
                    receivable_jama = productSold.accountcharges,
                    payable_naam = 0,
                    productname = productSold.productname,
                    weight = productSold.weight,
                    purchaserid = productSold.purchaserid,
                    sellerid = productSold.sellerid,
                    sellertypecode = productSold.sellertypecde,
                    purchasertypecode = productSold.purchasertypecde,
                    totalpayable_naam = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.payable_naam) + productSold.price : productSold.price,
                    totalreceivable_jama = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.receivable_jama) : 0
                };
                dbContext.OtherKhatas.Add(ok);
                //here collecting information about labour khata so as to calculate previous values of naam and jama
                khatatypecode = KhataType.Sootli.GetStringValue();
                resultOtherKhata = from n in dbContext.OtherKhatas where n.khatatypecde == khatatypecode select n;//activity code indicates it is khata agains purchase

                ok = new OtherKhata()
                {
                    activitycode = ActivityType.Sale.GetStringValue(),
                    khatatypecde = KhataType.Sootli.GetStringValue(),
                    date = System.DateTime.Now,
                    receivable_jama = productSold.thread,
                    payable_naam = 0,
                    productname = productSold.productname,
                    weight = productSold.weight,
                    purchaserid = productSold.purchaserid,
                    sellerid = productSold.sellerid,
                    sellertypecode = productSold.sellertypecde,
                    purchasertypecode = productSold.purchasertypecde,
                    totalpayable_naam = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.payable_naam) + productSold.price : productSold.price,
                    totalreceivable_jama = (resultOtherKhata != null && resultOtherKhata.Count() > 0) ? resultOtherKhata.Sum(p => p.receivable_jama) : 0
                };
                dbContext.OtherKhatas.Add(ok);

            #endregion

            dbContext.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
        private void resetAftersave()
        {
            saleProduct = new saleproduct() { date = DateTime.Now, isenglishvisible = CONTROLLER.ISENGLISHVISIBLE, isurduvisible = CONTROLLER.ISURDUVISIBLE };

            this.grdSaleProduct.DataContext = saleProduct;

        }