예제 #1
0
        public JsonResult CreateItem(ItemVM item, ItemVMInfo iteminf)
        {
            bool   status = false;
            string mes    = "";

            if (ModelState.IsValid)
            {
                using (LIVEEntities db = new LIVEEntities())
                {
                    FrdItem nw = new FrdItem();
                    nw.ItemNo          = item.ItemNo;
                    nw.ItemCode        = item.ItemCode;
                    nw.ItemName        = item.ItemName;
                    nw.ItemDescription = item.ItemDescription;
                    nw.ItemType        = item.ItemType;
                    nw.ItemTypeCode    = item.ItemTypeCode;
                    nw.ItemUnitCode    = item.ItemUnitCode;
                    nw.PlantCode       = item.PlantCode;
                    nw.ItemMachineCode = item.ItemMachineCode;
                    nw.UnitPrice       = item.UnitPrice;
                    nw.TaxFlag         = "Y";
                    nw.ConvertValue    = item.ConvertValue;
                    nw.UseFor          = "User recomended";
                    nw.Show            = "N";
                    nw.CreateBy        = Session["Name"].ToString();
                    nw.CreateDate      = DateTime.Now;
                    db.FrdItems.Add(nw);
                    db.SaveChanges();

                    FrdItemInfo inf = new FrdItemInfo();
                    inf.PlantID  = item.PlantCode;
                    inf.ItemID   = item.ItemNo;
                    inf.ItemCode = item.ItemTypeCode.ToString();
                    inf.ItemType = item.ItemType;
                    //inf.ItemUse = iteminf.ItemUse;
                    inf.MachineID  = item.ItemMachineCode;
                    inf.AlmariCode = iteminf.AlmariCode;
                    inf.AlmariDesc = "Emptynit";
                    inf.ItemSize   = "size";
                    inf.RowID      = iteminf.RowID;
                    inf.RacID      = iteminf.RacID;
                    inf.BinID      = iteminf.BinID;
                    inf.Location   = item.Location;
                    db.FrdItemInfoes.Add(inf);
                    db.SaveChanges();
                    status = true;
                }
            }
            else
            {
                status = false;
            }
            return(new JsonResult {
                Data = new { status = status, mes = mes }
            });
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "SupplierID,SupplierCode,SupplierName,SupplierAddress,PhoneNumber,MobileNumber,EmailAddress,Status,ZoneCode,BranchCode,MultiFlag,Remarks,ContactPerson")] FrdSupplier frdSupplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(frdSupplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(frdSupplier));
 }
예제 #3
0
        public ActionResult Create([Bind(Include = "Id,ItemNo,ItemCode,ItemName,ItemDescription,ItemType,ItemTypeCode,ItemUnitCode,PlantCode,ItemMachineCode,UnitPrice,TaxFlag,ConvertValue,UseFor,Show,CreateBy,CreateDate")] FrdItem frdItem)
        {
            if (ModelState.IsValid)
            {
                db.FrdItems.Add(frdItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(frdItem));
        }
예제 #4
0
 public ActionResult CreateItem(ItemVM item)
 {
     using (LIVEEntities db = new LIVEEntities())
     {
         FrdItem nw = new FrdItem();
         nw.ItemNo          = item.ItemNo;
         nw.ItemCode        = item.ItemCode;
         nw.ItemName        = item.ItemName;
         nw.ItemDescription = item.ItemDescription;
         nw.ItemType        = item.ItemType;
         nw.ItemTypeCode    = item.ItemTypeCode;
         nw.ItemUnitCode    = item.ItemUnitCode;
         nw.PlantCode       = item.PlantCode;
         nw.ItemMachineCode = item.ItemMachineCode;
         nw.UnitPrice       = item.UnitPrice;
         nw.TaxFlag         = item.TaxFlag;
         nw.ConvertValue    = item.ConvertValue;
         nw.UseFor          = item.UseFor;
         nw.Show            = item.Show;
         nw.CreateBy        = Session["Name"].ToString();
         nw.CreateDate      = DateTime.Now;
         db.FrdItems.Add(nw);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
예제 #5
0
        public ActionResult SaveData(RequestVM D)
        {
            bool   status = false;
            string mes    = "";
            var    w      = (from y in databaseManager.sUsers
                             where y.UserID.ToString() == User.Identity.Name
                             select new { y.PlantNo }).FirstOrDefault();
            var    wn       = databaseManager.sPlants.Where(x => x.PlantNo == w.PlantNo).FirstOrDefault();
            string s1       = w.PlantNo.ToString();
            string s2       = string.Concat(s1 + "1000000");
            int    reqno    = Convert.ToInt32(s2);
            var    maxreqno = (from n in databaseManager.FrdRequestMasters where n.PlantID == w.PlantNo select n.ReqID).DefaultIfEmpty(reqno).Max();
            var    maxrNo   = maxreqno + 1;
            int    v        = maxrNo;

            using (LIVEEntities ddd = new LIVEEntities())
            {
                FrdRequestMaster dbo = new FrdRequestMaster();
                {
                    dbo.ReqID      = maxrNo;
                    dbo.PlantID    = D.PlantID;
                    dbo.DeptID     = D.DeptID;
                    dbo.ReqDate    = DateTime.Today;
                    dbo.CustomerID = Convert.ToInt32(User.Identity.Name);
                    dbo.RefNo      = D.RefNo;
                    dbo.Remarks    = D.Remarks;
                    dbo.Status     = "I";
                    dbo.CreateDate = DateTime.Now;
                    dbo.CreateBy   = User.Identity.Name;
                };
                ddd.FrdRequestMasters.Add(dbo);
                foreach (var i in D.reqdtl)
                {
                    FrdRequestDetail obd = new FrdRequestDetail();
                    {
                        obd.PlantID   = D.PlantID;
                        obd.ReqID     = maxrNo;
                        obd.ItemID    = i.ItemID;
                        obd.Quantity  = i.Quantity;
                        obd.UnitPrice = 0;
                        obd.TotalAmt  = 0;
                        ddd.FrdRequestDetails.Add(obd);
                    }
                }
                ddd.SaveChanges();
                status = true;
                ddd.Dispose();
                ModelState.Clear();
            }
            return(new JsonResult {
                Data = new { status = status, mes = mes, v = v }
            });
        }
예제 #6
0
        public ActionResult SaveUpdate(ChangeVM D)
        {
            bool   status = false;
            string mes    = "";
            var    w      = (from y in databaseManager.sUsers
                             where y.UserID.ToString() == User.Identity.Name
                             select new { y.UserID }).FirstOrDefault();

            try
            {
                using (var transaction = databaseManager.Database.BeginTransaction())
                {
                    if (ModelState.IsValid)
                    {
                        var result = databaseManager.sUsers.SingleOrDefault(b => b.UserID == w.UserID);
                        if (result != null)
                        {
                            result.UserPass = D.NewPass;
                            result.UserPin  = D.UserPass;
                        }
                        databaseManager.SaveChanges();
                        transaction.Commit();
                        status = true;
                        databaseManager.Dispose();
                        ModelState.Clear();
                    }
                    else
                    {
                        status = false;
                        transaction.Rollback();
                    }
                    return(new JsonResult {
                        Data = new { status = status, mes = mes }
                    });
                }
            }
            catch (Exception ex)
            {
                string mess = ex.Message;
                return(Json(new { status = "error", message = "Error Generate" }));
            }
        }
예제 #7
0
        public ActionResult Create(FrdSupplier frdSupplier)
        {
            LIVEEntities db = new LIVEEntities();

            try
            {
                if (ModelState.IsValid)
                {
                    FrdSupplier sp = new FrdSupplier();
                    sp.SupplierID      = frdSupplier.SupplierID;
                    sp.SupplierCode    = frdSupplier.SupplierCode;
                    sp.SupplierName    = frdSupplier.SupplierName;
                    sp.SupplierAddress = frdSupplier.SupplierAddress;
                    sp.PhoneNumber     = frdSupplier.PhoneNumber;
                    sp.MobileNumber    = frdSupplier.MobileNumber;
                    sp.EmailAddress    = frdSupplier.EmailAddress;
                    sp.ZoneCode        = frdSupplier.ZoneCode;
                    sp.BranchCode      = frdSupplier.BranchCode;
                    sp.Remarks         = frdSupplier.Remarks;
                    sp.VATRegNo        = "222";
                    sp.Status          = "ACT";
                    db.FrdSuppliers.Add(sp);
                    db.SaveChanges();
                }
            }

            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            return(RedirectToAction("Index"));
        }
예제 #8
0
 public ActionResult CreateUser(UserReqVM user)
 {
     using (LIVEEntities db = new LIVEEntities())
     {
         sUser nw = new sUser();
         nw.UserID        = user.UserID;
         nw.UserName      = user.UserName;
         nw.UserPass      = user.UserPass;
         nw.UserPin       = user.UserPin;
         nw.RoleId        = user.RoleId;
         nw.MobileNo      = user.MobileNo;
         nw.PlantNo       = user.PlantNo;
         nw.Email         = user.Email;
         nw.UserStatus    = "ACT";
         nw.LoginType     = "A";
         nw.ActiveSession = 0;
         nw.CreateBy      = User.Identity.Name;
         nw.CreateDate    = DateTime.Now;
         db.sUsers.Add(nw);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult MyTransaction(TransactionVM D)
        {
            bool   status = false;
            string mes    = "";
            var    w      = (from y in databaseManager.sUsers
                             where y.UserID.ToString() == User.Identity.Name
                             select new { y.PlantNo }).FirstOrDefault();
            var    wn       = databaseManager.sPlants.Where(x => x.PlantNo == w.PlantNo).FirstOrDefault();
            string s1       = w.PlantNo.ToString();
            string s2       = string.Concat(s1 + "7000000");
            int    reqno    = Convert.ToInt32(s2);
            var    maxreqno = (from n in databaseManager.FrdPurchases where n.PlantID == w.PlantNo select n.ReceivedTranNo).DefaultIfEmpty(reqno).Max();
            var    maxrNo   = maxreqno + 1;
            string Code     = string.Concat("REC" + maxreqno);
            int    v        = maxrNo;

            try
            {
                using (var transaction = databaseManager.Database.BeginTransaction())
                {
                    if (ModelState.IsValid)
                    {
                        FrdPurchase dbo = new FrdPurchase();
                        {
                            dbo.ReceivedTranNo = maxrNo;
                            dbo.PlantID        = D.PlantID;
                            dbo.ReceivedTranNo = maxrNo;
                            dbo.TranDate       = DateTime.Today;
                            dbo.RefOrderNo     = D.RefOrderNo;
                            dbo.LCNo           = D.LCNo;
                            dbo.LocalForeign   = D.LocalForeign;
                            dbo.SupplierID     = D.SupplierID;
                            dbo.IndentNo       = D.IndentNo;
                            dbo.TotalQty       = D.TotalQty;
                            dbo.TotalPrice     = D.TotalPrice;
                            dbo.Remarks        = D.Remarks;
                            dbo.Status         = "REC";
                            dbo.RefInvoice     = D.RefInvoice;
                            dbo.CreateBy       = User.Identity.Name;
                            dbo.CreateDate     = DateTime.Now;
                        };
                        databaseManager.FrdPurchases.Add(dbo);
                        foreach (var i in D.reqdtl)
                        {
                            FrdPurchaseInfo obd = new FrdPurchaseInfo();
                            {
                                obd.PlantID   = D.PlantID;
                                obd.TranRefNo = maxrNo;
                                obd.ItemCode  = i.ItemCode;
                                obd.Qty       = i.Qty;
                                obd.UnitPrice = i.UnitPrice;
                                databaseManager.FrdPurchaseInfoes.Add(obd);
                            }
                            if (i.ItemCode != 0 && D.PlantID != 0)
                            {
                                databaseManager.spStockProduct(D.PlantID, i.ItemCode, 1, Convert.ToInt32(i.Qty), i.Qty, i.UnitPrice);
                            }
                        }
                        var result = databaseManager.FrdReceiveMasters.SingleOrDefault(b => b.ReqRecID == D.RefOrderNo);
                        if (result != null)
                        {
                            result.Status = "COM";
                            //databaseManager.SaveChanges();
                        }

                        databaseManager.SaveChanges();
                        transaction.Commit();
                        status = true;
                        databaseManager.Dispose();
                        ModelState.Clear();
                    }
                    else
                    {
                        status = false;
                        transaction.Rollback();
                    }
                    return(new JsonResult {
                        Data = new { status = status, mes = mes, v = v }
                    });
                }
            }
            catch (Exception ex)
            {
                string mess = ex.Message;
                return(Json(new { status = "error", message = "Error Generate" }));
            }
        }
예제 #10
0
        public ActionResult SaveReceived(ReceiveVM D)
        {
            bool   status = false;
            string mes    = "";
            var    w      = (from y in databaseManager.sUsers
                             where y.UserID.ToString() == User.Identity.Name
                             select new { y.PlantNo }).FirstOrDefault();
            var    wn       = databaseManager.sPlants.Where(x => x.PlantNo == w.PlantNo).FirstOrDefault();
            string s1       = w.PlantNo.ToString();
            string s2       = string.Concat(s1 + "1000000");
            int    reqno    = Convert.ToInt32(s2);
            var    maxreqno = (from n in databaseManager.FrdReceiveMasters where n.PlantID == w.PlantNo select n.ReqRecID).DefaultIfEmpty(reqno).Max();
            var    maxrNo   = maxreqno + 1;
            int    v        = maxrNo;

            try
            {
                // using (LIVEEntities ddd = new LIVEEntities())
                using (var transaction = databaseManager.Database.BeginTransaction())
                {
                    if (ModelState.IsValid)
                    {
                        FrdReceiveMaster dbo = new FrdReceiveMaster();
                        {
                            dbo.ReqRecID = maxrNo;
                            dbo.PlantID  = D.PlantID;
                            dbo.DeptID   = D.DeptID;
                            dbo.RecDate  = DateTime.Today;
                            dbo.ReqID    = D.ReqID;
                            //dbo.RefNo = D.RefNo;
                            dbo.SupplierID = D.SupplierID;
                            dbo.UserNote   = D.UserNote;
                            dbo.TypeCode   = D.TypeCode;
                            if (D.TypeCode == 20)
                            {
                                dbo.AppBy   = "XXXXX";
                                dbo.AppFlag = "O";
                                dbo.Status  = "PEN";
                            }
                            else
                            {
                                dbo.AppBy   = "NA";
                                dbo.AppFlag = "N";
                                dbo.Status  = "COM";
                            }
                            dbo.CreateDate = DateTime.Now;
                            dbo.CreateBy   = User.Identity.Name;
                        };
                        databaseManager.FrdReceiveMasters.Add(dbo);
                        foreach (var i in D.itemdtl)
                        {
                            FrdReceiveDetail obd = new FrdReceiveDetail();
                            {
                                obd.PlantID   = D.PlantID;
                                obd.ReqRecID  = maxrNo;
                                obd.ItemID    = i.ItemID;
                                obd.Quantity  = i.Quantity;
                                obd.UnitPrice = i.UnitPrice;
                                databaseManager.FrdReceiveDetails.Add(obd);
                            }
                        }
                        var result = databaseManager.FrdRequestMasters.SingleOrDefault(b => b.ReqID == D.ReqID);
                        if (result != null)
                        {
                            result.Status = "A";
                            databaseManager.SaveChanges();
                        }
                        databaseManager.SaveChanges();
                        transaction.Commit();
                        status = true;
                        databaseManager.Dispose();
                        ModelState.Clear();
                    }

                    else
                    {
                        status = false;
                        transaction.Rollback();
                    }
                    return(new JsonResult {
                        Data = new { status = status, mes = mes, v = v }
                    });
                }
            }
            catch (Exception ex)
            {
                string mess = ex.Message;
                return(Json(new { status = "error", message = "Error Generate" }));
            }
        }