public ActionResult EditLocation(mLocation location) { location.SiteCode = "thissite"; location.CapacityUnity = "wew"; try { mLocation Location = new mLocation(); Location = (from u in db.mLocations.ToList() where u.LocationCode == location.LocationCode select u).FirstOrDefault(); Location.LocationName = location.LocationName; Location.LocationDesc = location.LocationDesc; Location.Update_User = "******"; Location.Update_Date = DateTime.Now; mLocation checker = (from c in db.mLocations where c.LocationName == location.LocationName && c.LocationDesc == location.LocationDesc && c.Is_Deleted == false select c).FirstOrDefault(); if (checker == null) { db.Entry(Location).State = EntityState.Modified; db.SaveChanges(); } else { return(Json(new { result = "failed" }, JsonRequestBehavior.AllowGet)); } } catch (Exception err) { } return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet)); }
public static string PMSaveWLocation(object WLocationInfo, string LocationID) { string result = ""; CustomProfile profile = CustomProfile.GetProfile(); iWarehouseClient Warehouseclient = new iWarehouseClient(); mLocation loc = new mLocation(); tSKUTransaction skutrans = new tSKUTransaction(); try { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary = (Dictionary <string, object>)WLocationInfo; loc.ShelfID = long.Parse(dictionary["ShelfID"].ToString()); loc.Code = dictionary["LocationCode"].ToString(); loc.AliasCode = dictionary["AliasCode"].ToString(); loc.SortCode = long.Parse(dictionary["SortCode"].ToString()); loc.LocationType = dictionary["LocationType"].ToString(); loc.CapacityIn = long.Parse(dictionary["CapacityIn"].ToString()); loc.Capacity = decimal.Parse(dictionary["Capacity"].ToString()); loc.VelocityType = dictionary["VelocityType"].ToString(); loc.CompanyID = long.Parse(dictionary["CompanyID"].ToString()); loc.CustomerID = long.Parse(dictionary["CustomerID"].ToString()); loc.Active = dictionary["Active"].ToString().Trim(); loc.WarehouseID = long.Parse(dictionary["WarehouseID"].ToString()); skutrans.ClosingBalance = 0; skutrans.InQty = 0; skutrans.OutQty = 0; skutrans.CreatedBy = profile.Personal.UserID; skutrans.CreationDate = DateTime.Now; skutrans.CompanyID = long.Parse(dictionary["CompanyID"].ToString()); skutrans.CustomerID = long.Parse(dictionary["CustomerID"].ToString()); if (LocationID != "0") { loc.ID = long.Parse(LocationID); loc.CreatedBy = profile.Personal.UserID; loc.CreationDate = DateTime.Now; long LocID = Warehouseclient.SaveWarehouseLocation(loc, profile.DBConnection._constr); } else { loc.AvailableBalance = 0; loc.CreatedBy = profile.Personal.UserID; loc.CreationDate = DateTime.Now; long LocID = Warehouseclient.SaveWarehouseLocation(loc, profile.DBConnection._constr); skutrans.LocationID = LocID; Warehouseclient.AddRecordInSkuTransaction(skutrans, profile.DBConnection._constr); } result = "Location saved successfully"; } catch { result = "Some error occurred"; } finally { Warehouseclient.Close(); } return(result); }
public ActionResult CreateLocation(mLocation location) { location.SiteCode = "thissite"; location.CapacityUnity = "wew"; string gencode = string.Empty; string lastgencode = (from u in db.mLocations.ToList() orderby u.LocationCode descending select u.LocationCode).FirstOrDefault(); if (lastgencode == null) { gencode = "LOC0001"; } else { gencode = lastgencode.Substring(3); int upId = Convert.ToInt32(gencode.TrimStart(new char[] { '0' })) + 1; gencode = string.Format("LOC{0}", upId.ToString().PadLeft(4, '0')); } location.LocationCode = gencode; location.Is_Deleted = false; location.Create_Date = DateTime.Now; location.Create_User = user.UserID; location.Update_Date = DateTime.Now; location.Update_User = user.UserID; mLocation checker = (from c in db.mLocations where c.LocationName == location.LocationName && c.LocationDesc == location.LocationDesc && c.SiteCode == location.SiteCode && c.Is_Deleted == false select c).FirstOrDefault(); if (checker == null) { try { db.mLocations.Add(location); db.SaveChanges(); } catch (Exception err) { } } else { return(Json(new { result = "failed" }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteLocation(string LocationCode) { mLocation location = new mLocation(); location = (from u in db.mLocations.ToList() where u.LocationCode == LocationCode select u).FirstOrDefault(); location.Is_Deleted = true; location.Update_Date = DateTime.Now; location.Update_User = user.UserID; db.Entry(location).State = EntityState.Modified; db.SaveChanges(); return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet)); }
public long SaveWarehouseLocation(mLocation wlocation, string[] conn) { try { BISPL_CRMDBEntities db = new BISPL_CRMDBEntities(svr.GetEntityConnection(conn)); if (wlocation.ID == 0) { db.mLocations.AddObject(wlocation); db.SaveChanges(); } else { db.mLocations.Attach(wlocation); db.ObjectStateManager.ChangeObjectState(wlocation, EntityState.Modified); db.SaveChanges(); } return(wlocation.ID); } catch { return(0); } }