public ActionResult DeleteSupplier(int Supplier_Id) { UserResultModel resultdata = new UserResultModel(); M_Supplier Supplier = new M_Supplier { Supplier_Id = Supplier_Id, LastModifiedBy = UserHelper.GetCurrentUserName() }; int OperationStatus = SupplierProxy.Instance.DeleteSupplier(ConfigExtension.GetWebApiUri, "api/Supplier/DeleteSupplier/" + Supplier.Supplier_Id + "?LastModifiedBy=" + Supplier.LastModifiedBy, Supplier); if (OperationStatus == (int)operation_status.Delete) { resultdata.operationstatuscode = (int)operation_status.Delete;//message when Delete record. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgDelete"); } else if (OperationStatus == (int)operation_status.Delete_Prevent) { resultdata.operationstatuscode = (int)operation_status.Delete;//message when Delete record. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgDeletePrevent"); } else { resultdata.operationstatuscode = (int)operation_status.Error;//message when Error record. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgError"); } return(Json(resultdata, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(M_Supplier objSupplier) { try { if (ModelState.IsValid) { if (!string.IsNullOrWhiteSpace(Convert.ToString(objSupplier.Id))) { var vObj = _blSupplier.GetById(objSupplier.Id); if (vObj != null) { vObj.Name = objSupplier.Name; vObj.Phone = objSupplier.Phone; vObj.Email = objSupplier.Email; vObj.Address = objSupplier.Address; vObj.ModifyDate = DateTime.Now; vObj.ModifyBy = _objAuthentication.UserName; _blSupplier.Update(vObj); } } } } catch (Exception ex) { throw ex; } return(RedirectToAction("Index", "Supplier")); }
public JsonResult GetList(M_Supplier objSupplier) { List <M_Supplier> ObjList = new List <M_Supplier>(); try { var vList = _blSupplier.GetList(objSupplier); if (vList.Count > 0) { foreach (var item in vList) { var vObjItemUser = new M_Supplier() { Id = item.Id, Name = item.Name, Phone = item.Phone, Email = item.Email, Address = item.Address, CreatedBy = item.CreatedBy, CreatedDate = item.CreatedDate, ModifyBy = item.ModifyBy, ModifyDate = item.ModifyDate }; ObjList.Add(vObjItemUser); } } } catch (Exception ex) { throw ex; } return(Json(ObjList, JsonRequestBehavior.AllowGet)); }
//查询单个(查ID) public int Select(ref M_Supplier Obj, int ID, ref string ErrMsg) { SqlConnection conn; using (conn = CreatConn()) { SqlCommand cmd = new SqlCommand($"select ID,Disable_BL,SupplierName,SupplierNumber,DeadLine from {TableName} where ID = {ID}", conn); SqlDataReader sdr; try { conn.Open(); sdr = cmd.ExecuteReader(); while (sdr.Read()) { Obj.ID = (int)sdr["ID"]; Obj.DeadLine = (long)sdr["DeadLine"]; Obj.Disable_BL = (int)sdr["Disable_BL"]; Obj.SupplierName = (string)sdr["SupplierName"]; Obj.SupplierNumber = (string)sdr["SupplierNumber"]; return 1; } return -1; } catch (Exception ex) { ErrMsg = ex.Message; return -1; } finally { cmd.Dispose(); } } }
public ActionResult SupplierList() { M_Supplier objModel = new M_Supplier(); var vlist = _blSupplier.GetList(objModel).Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).OrderBy(x => x.Text).ToList(); return(Json(vlist, JsonRequestBehavior.AllowGet)); }
public int AddUpdateSupplier(M_Supplier Supplier) { var return_Status = new ObjectParameter("return_Status", typeof(int)); using (InventoryToolDBEntities entity = new InventoryToolDBEntities()) { entity.UpdateSupplier(Supplier.Supplier_Id, Supplier.Supplier_Code, Supplier.Supplier_Name, Supplier.Contact_No, Supplier.Email, Supplier.Address1, Supplier.Address2, Supplier.City, Supplier.State, Supplier.PinCode, Supplier.TinNo, Supplier.VatNo, Supplier.Note, Supplier.LastModifiedBy, return_Status); return(Convert.ToInt32(return_Status.Value)); } }
//查询多个(查ID) public int Select(ref List<M_Supplier> Obj, List<int> ID, ref string ErrMsg) { SqlConnection conn; using (conn = CreatConn()) { SqlCommand cmd = new SqlCommand($"select ID,Disable_BL,SupplierName,SupplierNumber,DeadLine from {TableName} where ID = @ID", conn); SqlDataReader sdr; SqlParameter par = new SqlParameter("@ID", SqlDbType.Int); cmd.Parameters.Add(par); int tmpOut = 0; try { conn.Open(); foreach (int i in ID) { cmd.Parameters["@ID"].Value = i; sdr = cmd.ExecuteReader(); while (sdr.Read()) { M_Supplier TmpObj = new M_Supplier(); TmpObj.ID = (int)sdr["ID"]; TmpObj.DeadLine = (long)sdr["DeadLine"]; TmpObj.Disable_BL = (int)sdr["Disable_BL"]; TmpObj.SupplierName = (string)sdr["SupplierName"]; TmpObj.SupplierNumber = (string)sdr["SupplierNumber"]; Obj.Add(TmpObj); tmpOut++; } sdr.Close(); } } catch (Exception ex) { ErrMsg = ex.Message; return -1; } finally { cmd.Dispose(); } if (ID.Count() == tmpOut) { return 1; } else { return -1; } } }
//更新单个(查ID) public int Update(M_Supplier Obj, ref string ErrMsg) { SqlConnection conn; using (conn = CreatConn()) { SqlCommand cmd = new SqlCommand($"update {TableName} set Disable_BL = @Disable_BL, SupplierName = @SupplierName, SupplierNumber = @SupplierNumber, DeadLine = @DeadLine where ID = @ID", conn); SqlParameter par = new SqlParameter("@Disable_BL", SqlDbType.Int); par.Value = Obj.Disable_BL; cmd.Parameters.Add(par); par = new SqlParameter("@SupplierName", SqlDbType.Char, 100); par.Value = Obj.SupplierName; cmd.Parameters.Add(par); par = new SqlParameter("@SupplierNumber", SqlDbType.Char, 50); par.Value = Obj.SupplierNumber; cmd.Parameters.Add(par); par = new SqlParameter("@DeadLine", SqlDbType.BigInt); par.Value = Obj.DeadLine; cmd.Parameters.Add(par); par = new SqlParameter("@ID", SqlDbType.Int); par.Value = Obj.ID; cmd.Parameters.Add(par); try { conn.Open(); if (cmd.ExecuteNonQuery() > 0) { return 1; } else { return -1; } } catch (Exception ex) { ErrMsg = ex.Message; return -1; } finally { cmd.Dispose(); } } }
public ActionResult AddUpdateSupplier(M_Supplier Supplier) { UserResultModel resultdata = new UserResultModel(); if (Supplier != null) { Supplier.LastModifiedBy = UserHelper.GetCurrentUserName(); } try { int OperationStatus = SupplierProxy.Instance.AddUpdateSupplier(ConfigExtension.GetWebApiUri, "api/Supplier/AddUpdateSupplier", Supplier); if (OperationStatus == (int)operation_status.Insert) { resultdata.operationstatuscode = (int)operation_status.Insert;//message when inserted. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgInsert"); } else if (OperationStatus == (int)operation_status.Update) { resultdata.operationstatuscode = (int)operation_status.Update;//message when Update. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgUpdate"); } else if (OperationStatus == (int)operation_status.Duplicate_Record) { resultdata.operationstatuscode = (int)operation_status.Duplicate_Record;//message when duplicate record. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgDuplicate"); } else if (OperationStatus == (int)operation_status.Update_Prevent) { resultdata.operationstatuscode = (int)operation_status.Duplicate_Record;//message when duplicate record. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgUpdatePrevent"); } else { resultdata.operationstatuscode = (int)operation_status.Error;//message when duplicate record. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgError"); } } catch (Exception ex) { resultdata.operationstatuscode = (int)operation_status.Error;//message when duplicate record. resultdata.messagedata = UserMessage.ResourceManager.GetString("msgError"); resultdata.message = ex.Message; } return(Json(resultdata, JsonRequestBehavior.AllowGet)); }
//插入单个 public int Insert(ref M_Supplier Obj, ref string ErrMsg) { SqlConnection conn; using (conn = CreatConn()) { SqlCommand cmd = new SqlCommand($"insert into {TableName} (Disable_BL,SupplierName,SupplierNumber,DeadLine) values (@Disable_BL,@SupplierName,@SupplierNumber,@DeadLine);select @@IDENTITY as int", conn); SqlParameter par = new SqlParameter("@Disable_BL", SqlDbType.Int); par.Value = Obj.Disable_BL; cmd.Parameters.Add(par); par = new SqlParameter("@SupplierName", SqlDbType.Char, 100); par.Value = Obj.SupplierName; cmd.Parameters.Add(par); par = new SqlParameter("@SupplierNumber", SqlDbType.Char, 50); par.Value = Obj.SupplierNumber; cmd.Parameters.Add(par); par = new SqlParameter("@DeadLine", SqlDbType.BigInt); par.Value = Obj.DeadLine; cmd.Parameters.Add(par); try { conn.Open(); decimal d = (decimal)cmd.ExecuteScalar(); Obj.ID = (int)d; if (Obj.ID > 0) { return 1; } else { return -1; } } catch (Exception ex) { ErrMsg = ex.Message; return -1; } finally { cmd.Dispose(); } } }
public M_Supplier Delete(M_Supplier ObjSupplier) { try { using (_objUnitOfWork = new UnitOfWork()) { _objUnitOfWork._M_Supplier_Repository.Delete(ObjSupplier.Id); _objUnitOfWork.Save(); } } catch (Exception ex) { throw ex; } return(ObjSupplier); }
public M_Supplier GetFirstOrDefault(M_Supplier ObjSupplier) { var ReturnSupplierObj = new M_Supplier(); try { using (_objUnitOfWork = new UnitOfWork()) { ReturnSupplierObj = _objUnitOfWork._M_Supplier_Repository.GetFirstOrDefault(x => x.Name == ObjSupplier.Name); } } catch (Exception ex) { throw ex; } return(ReturnSupplierObj); }
public M_Supplier GetById(Guid UserId) { var ObjSupplier = new M_Supplier(); try { using (_objUnitOfWork = new UnitOfWork()) { ObjSupplier = _objUnitOfWork._M_Supplier_Repository.GetById(UserId); } } catch (Exception ex) { throw ex; } return(ObjSupplier); }
public ActionResult Edit(string Id) { M_Supplier vModel = new M_Supplier(); if (!string.IsNullOrWhiteSpace(Id)) { var vDetails = _blSupplier.GetById(new Guid(Id)); if (vDetails != null) { vModel.Id = vDetails.Id; vModel.Name = vDetails.Name; vModel.Phone = vDetails.Phone; vModel.Email = vDetails.Email; vModel.Address = vDetails.Address; } } return(View(vModel)); }
public ActionResult Create(M_Supplier objSupplier) { try { bool bAnyError = false; if (ModelState.IsValid) { var vNameExists = _blSupplier.GetFirstOrDefault(objSupplier); if (vNameExists != null) { ViewBag.ErrorMsg = "Supplier Name alreay exists in our system"; bAnyError = true; } if (bAnyError == false) { M_Supplier _Obj_M_Supplier = new M_Supplier() { Id = Guid.NewGuid(), Name = objSupplier.Name, Phone = objSupplier.Phone, Email = objSupplier.Email, Address = objSupplier.Address, CreatedBy = _objAuthentication.UserName, CreatedDate = DateTime.Now }; var vReturnObj = _blSupplier.Create(_Obj_M_Supplier); } } else { bAnyError = true; } if (bAnyError) { return(View(objSupplier)); } return(RedirectToAction("Index", "Supplier")); } catch (Exception ex) { throw ex; } }
public ActionResult Delete(M_Supplier objSupplier) { try { if (!string.IsNullOrWhiteSpace(Convert.ToString(objSupplier.Id))) { var vObj = _blSupplier.GetById(objSupplier.Id); if (vObj != null) { _blSupplier.Delete(objSupplier); } } } catch (Exception ex) { throw ex; } return(Json(objSupplier)); }
public List <M_Supplier> GetList(M_Supplier ObjSupplier) { var ObjList = new List <M_Supplier>(); try { using (_objUnitOfWork = new UnitOfWork()) { var queryObjList = _objUnitOfWork._M_Supplier_Repository.Query(); if (!string.IsNullOrWhiteSpace(ObjSupplier.Name)) { queryObjList = queryObjList.Where(x => x.Name.Contains(ObjSupplier.Name)); } ObjList = queryObjList.OrderBy(x => x.Name).ToList(); } } catch (Exception ex) { throw ex; } return(ObjList); }
public int DeleteSupplier(string apiUri, string requestUri, M_Supplier Supplier) { var result = ProxyHelper.PostRequestToApi(apiUri, requestUri, Supplier); return(JsonConvert.DeserializeObject <int>(result)); }
//查询单个(查ID) public static int Select(ref M_Supplier Obj, int ID, ref string ErrMsg) { I_Supplier I = (D_Supplier)SimpleFactory.CreateObject(DBType.Supplier); return I.Select(ref Obj, ID, ref ErrMsg); }
//更新单个(查ID) public static int Update(M_Supplier Obj, ref string ErrMsg) { I_Supplier I = (D_Supplier)SimpleFactory.CreateObject(DBType.Supplier); return I.Update(Obj, ref ErrMsg); }