public List <Stove> GetStoves()
 {
     using (LPGContext db = new LPGContext())
     {
         return(db.Stoves.Where(x => x.type != "Regulator").Select(x => x).ToList());
     }
 }
 public Stove GetRegulators()
 {
     using (LPGContext db = new LPGContext())
     {
         return(db.Stoves.Where(x => x.type == "Regulator").FirstOrDefault());
     }
 }
 public List <Cylinder> GetCylinders()
 {
     using (LPGContext db = new LPGContext())
     {
         return(db.Cylinders.Select(x => x).ToList());
     }
 }
 public string AddStove(Stove s)
 {
     using (LPGContext db = new LPGContext())
     {
         db.Stoves.Add(s);
         db.SaveChanges();
         return("OK");
     }
 }
 public string SetStoves(string a, int c)
 {
     using (LPGContext db = new LPGContext())
     {
         var r = db.Stoves.Where(x => x.type == a).FirstOrDefault();
         r.Quentity = c;
         db.SaveChanges();
         return("OK");
     }
 }
 public string RemoveStove(string s)
 {
     using (LPGContext db = new LPGContext())
     {
         var r = db.Stoves.Where(x => x.type == s).FirstOrDefault();
         db.Stoves.Remove(r);
         db.SaveChanges();
         return("OK");
     }
 }
 public string SetRegulators(int a)
 {
     using (LPGContext db = new LPGContext())
     {
         var r = db.Stoves.Where(x => x.type == "Regulator").ToList();
         r.ForEach(s => s.Quentity = a);
         db.SaveChanges();
     }
     return("OK");
 }
 public string SetECylinders(string a, int c)
 {
     using (LPGContext db = new LPGContext())
     {
         var r = db.Cylinders.ToList();
         r.Where(x => x.type == a).ToList().ForEach(s => s.Quentity = s.Quentity - c);
         db.SaveChanges();
     }
     return("OKE");
 }
 public string SetStovePrice(string s, double a)
 {
     using (LPGContext db = new LPGContext())
     {
         var r = db.Stoves.Where(x => x.type == s).FirstOrDefault();
         r.Price = Math.Round(a, 2);
         db.SaveChanges();
         return("OK");
     }
 }
 public string SetCylPrice(string s, double a)
 {
     using (LPGContext db = new LPGContext())
     {
         var r = db.Cylinders.ToList();
         r.Where(x => x.type == s).ToList().ForEach(x => x.Price = Math.Round(a, 2));
         db.SaveChanges();
     }
     return("OK");
 }
 public string SetRegPrice(double a)
 {
     using (LPGContext db = new LPGContext())
     {
         var r = db.Stoves.Where(x => x.type == "Regulator").ToList();
         r.ForEach(s => s.Price = Math.Round(a, 2));
         db.SaveChanges();
     }
     return("OK");
 }
 public string TestConnection()
 {
     using (LPGContext test = new LPGContext())
     {
         try
         {
             return(test.DistributorUsers.FirstOrDefault().ToString());
         }
         catch (Exception e)
         {
             return("FAIL");
         }
     }
 }
Ejemplo n.º 13
0
        public int StoveTx(string cname, string prod, int qty, int cmno)
        {
            TxStoveRegulator tx = new TxStoveRegulator();
            Customer         c  = null;

            c = db.Customers.Where(x => x.CustomerName.Equals(cname)).FirstOrDefault();
            if (c != null)
            {
                tx.CustomerId   = c.CustomerId;
                tx.CustomerName = c.CustomerName;
            }
            else
            {
                tx.CustomerId   = 0;
                tx.CustomerName = cname;
            }
            tx.TxDate   = DateTime.Now;
            tx.Details  = prod;
            tx.Quentity = qty;
            var reg = db.Stoves.Where(x => x.type.Equals(prod)).FirstOrDefault();

            tx.Price  = reg.Price;
            tx.Amount = Math.Round(qty * tx.Price, 2);
            var gst = db.GSTRates.Where(x => x.Comodity.Equals("Stove")).FirstOrDefault();

            tx.CGST  = Math.Round(tx.Amount * gst.CGST / 100, 2);
            tx.SGST  = Math.Round(tx.Amount * gst.SGST / 100, 2);
            tx.Total = tx.Amount + tx.CGST + tx.SGST;
            int cmn = 0;

            if (cmno == 0)
            {
                cmn = db.txStoves.Select(x => x.CashMemoNo).Max(m => m) + 1;
            }
            else
            {
                cmn = cmno;
            }
            tx.CashMemoNo = cmn;
            db.txStoves.Add(tx);
            db.SaveChanges();
            using (LPGContext dbo = new LPGContext())
            {
                var result = dbo.Stoves.Where(x => x.type.Equals(prod)).FirstOrDefault();
                result.Quentity = result.Quentity - qty;
                dbo.SaveChanges();
            }
            return(cmn);
        }
Ejemplo n.º 14
0
        public TxCylinder BookingCylinderTx(int cid, int qty)
        {
            Customer        c  = db.Customers.Where(x => x.CustomerId == cid).FirstOrDefault();
            DistributorUser du = db.DistributorUsers.FirstOrDefault();
            TxCylinder      tc = new TxCylinder();

            tc.CustomerId   = c.CustomerId;
            tc.CustomerName = c.CustomerName;
            tc.TxDate       = DateTime.Now;
            string details = null;
            int    q       = 0;

            if (c.CustomerType.Equals("Industrial"))
            {
                q                  = qty;
                details            = db.CylCustMappings.Where(x => x.CustomerType.Equals("Industrial")).Select(s => s.CylenderType).FirstOrDefault();
                tc.CylinderDetails = details;
                tc.Quentity        = qty;
                tc.Price           = db.Cylinders.Where(x => x.type == details).FirstOrDefault().Price;
                tc.Amount          = Math.Round(qty * tc.Price, 2);
                var gst = db.GSTRates.Where(x => x.Comodity.Equals("Industrial Cylender")).FirstOrDefault();
                tc.CGST = Math.Round((tc.Amount * gst.CGST) / 100, 2);
                tc.SGST = Math.Round((tc.Amount * gst.SGST) / 100, 2);
            }
            else
            {
                CylCustMapping ccm = null;

                if (c.BankAccountNo == "")
                {
                    ccm     = db.CylCustMappings.Where(x => x.CustomerType.Equals(c.CustomerType) && x.CylenderType.Equals("14.2 KG Without Subsidy (F)")).FirstOrDefault();
                    details = ccm.CylenderType;
                    q       = ccm.NoCylender;
                }
                else
                {
                    ccm     = db.CylCustMappings.Where(x => x.CustomerType.Equals(c.CustomerType) && x.CylenderType.Equals("14.2 KG With Subsidy (F)")).FirstOrDefault();
                    details = ccm.CylenderType;
                    q       = ccm.NoCylender;
                }
                tc.CylinderDetails = details;
                tc.Quentity        = q;
                tc.Price           = db.Cylinders.Where(x => x.type == details).FirstOrDefault().Price;
                tc.Amount          = Math.Round(q * tc.Price, 2);
                var gst = db.GSTRates.Where(x => x.Comodity.Equals("Domestic Cylender")).FirstOrDefault();
                tc.CGST = Math.Round((tc.Amount * gst.CGST) / 100, 2);
                tc.SGST = Math.Round((tc.Amount * gst.SGST) / 100, 2);
            }
            int cmn = db.txCylinders.Select(x => x.CashMemoNo).Max(m => m) + 1;

            tc.CashMemoNo = cmn;
            tc.Total      = tc.Amount + tc.CGST + tc.SGST;
            var rec = db.txCylinders.Add(tc);

            db.SaveChanges();
            Synchronization.Synchronization syn = new Synchronization.Synchronization();
            syn.AddRecord("TxCylinders", "Add", rec.TxId);
            using (LPGContext dbo = new LPGContext())
            {
                var result = dbo.Cylinders.Where(x => x.type.Equals(details)).FirstOrDefault();
                result.Quentity = result.Quentity - q;
                dbo.SaveChanges();
            }
            using (LPGContext dbo1 = new LPGContext())
            {
                details = details.Substring(0, details.Length - 2);
                details = details + "E)";
                var result = dbo1.Cylinders.Where(x => x.type.Equals(details)).FirstOrDefault();
                result.Quentity = result.Quentity + q;
                dbo1.SaveChanges();
            }

            return(rec);
        }