예제 #1
0
        public Customer AddCustomer(Customer customer)
        {
            Customer c = cc.Customers.Add(customer);

            cc.SaveChanges();
            Synchronization.Synchronization syn = new Synchronization.Synchronization();
            syn.AddRecord("Customers", "Add", c.CustomerId);
            return(c);
        }
예제 #2
0
        public string DeleteCustomer(int cid)
        {
            var result = cc.Customers.Where(x => x.CustomerId == cid).FirstOrDefault();

            cc.Customers.Remove(result);
            cc.SaveChanges();
            Synchronization.Synchronization syn = new Synchronization.Synchronization();
            syn.AddRecord("Customers", "Delete" + result.DistributorCode, cid);
            return("OK");
        }
예제 #3
0
        public string UpdateCustomer(Customer customer)
        {
            Customer c = cc.Customers.Where(x => x.AadharNo.Equals(customer.AadharNo)).FirstOrDefault();

            c.CustomerName = customer.CustomerName;
            c.Gender       = customer.Gender;
            c.Address      = customer.Address;
            c.City         = customer.City;
            c.PinNo        = customer.PinNo;
            c.Taluka       = customer.Taluka;
            c.District     = customer.District;
            c.State        = customer.State;
            c.ContactNo    = customer.ContactNo;
            c.Email        = customer.Email;
            cc.SaveChanges();
            Synchronization.Synchronization syn = new Synchronization.Synchronization();
            syn.AddRecord("Customers", "Update", c.CustomerId);
            return("OK");
        }
예제 #4
0
        public string AddCylenderTx(string details, int qty)
        {
            DistributorUser du = db.DistributorUsers.FirstOrDefault();
            TxCylinder      tc = new TxCylinder();

            tc.CustomerId      = du.DistributorCode;
            tc.CustomerName    = du.DistributorName;
            tc.TxDate          = DateTime.Now;
            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);
            tc.CGST            = 0;
            tc.SGST            = 0;
            tc.Total           = tc.Amount;
            tc.CashMemoNo      = 0;
            db.txCylinders.Add(tc);
            db.SaveChanges();
            Synchronization.Synchronization syn = new Synchronization.Synchronization();
            syn.AddRecord("TxCylinders", "Add", db.txCylinders.Last().TxId);
            return("OK");
        }
예제 #5
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);
        }