public void Delete(SupplierCity ObjDelete) { var ObjToDelete = _context.SupplierCitys.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.SupplierCityID == ObjDelete.SupplierCityID); if (ObjToDelete != null) { _context.SupplierCitys.Remove(ObjToDelete); } }
private void ButtonAddMapping_Click(object sender, EventArgs e) { SupplierCity suppCity = new SupplierCity { Citycod_Code = TextEditCode.Text ?? string.Empty }; _selectedRecord.SupplierCity.Add(suppCity); BindSupplierCities(); GridViewSupplierCity.FocusedRowHandle = BindingSourceSupplierCity.Count - 1; }
private void FinalizeBindings() { BindingSource.EndEdit(); GridViewSupplierCity.CloseEditor(); GridViewSupplierCity.UpdateCurrentRow(); //Set the city code for each mapping just in case for (int rowCtr = 0; rowCtr < GridViewSupplierCity.DataRowCount; rowCtr++) { SupplierCity suppCity = (SupplierCity)GridViewSupplierCity.GetRow(rowCtr); suppCity.Citycod_Code = TextEditCode.Text ?? string.Empty; } BindingSourceSupplierCity.EndEdit(); }
public void Update(SupplierCity ObjUpdate) { var ObjToUpdate = _context.SupplierCitys.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.SupplierCityID == ObjUpdate.SupplierCityID); if (ObjToUpdate != null) { ObjToUpdate.ArabicName = ObjUpdate.ArabicName; ObjToUpdate.EnglishName = ObjUpdate.EnglishName; ObjToUpdate.SupplierCountryID = ObjUpdate.SupplierCountryID; ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime; ObjToUpdate.InsUserID = ObjUpdate.InsUserID; } }
private void ButtonDeleteMapping_Click(object sender, EventArgs e) { if (GridViewSupplierCity.FocusedRowHandle >= 0) { SupplierCity suppCity = (SupplierCity)GridViewSupplierCity.GetFocusedRow(); _selectedRecord.SupplierCity.Remove(suppCity); //Removing from the collection just removes the object from its parent, but does not mark //it for deletion, effectively orphaning it. This will cause foreign key errors when saving. //To flag for deletion, delete it from the context as well. _selectedRecord.SupplierCity.Remove(suppCity); _context.SupplierCity.DeleteObject(suppCity); BindSupplierCities(); } }
public JsonResult SaveSupplierCity(SupplierCityVM ObjToSave) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); var SupplierCityObj = new SupplierCity(); SupplierCityObj.InsDateTime = DateTime.Now; SupplierCityObj.InsUserID = userId; SupplierCityObj.CompanyID = UserInfo.fCompanyId; SupplierCityObj.SupplierCityID = ObjToSave.SupplierCityID; SupplierCityObj.SupplierCountryID = ObjToSave.SupplierCountryID; if (String.IsNullOrEmpty(ObjToSave.EnglishName)) { ObjToSave.EnglishName = ObjToSave.ArabicName; } SupplierCityObj.ArabicName = ObjToSave.ArabicName; SupplierCityObj.EnglishName = ObjToSave.EnglishName; if (!ModelState.IsValid) { string Err = " "; var errors = ModelState.Values.SelectMany(v => v.Errors); foreach (ModelError error in errors) { Err = Err + error.ErrorMessage + " * "; } Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + Err; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } _unitOfWork.SupplierCity.Add(SupplierCityObj); _unitOfWork.Complete(); _unitOfWork.SupplierCity.GetMaxSerial(UserInfo.fCompanyId).ToString(); Msg.Code = 1; Msg.Msg = Resources.Resource.AddedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
internal override bool isValid() { int requiredFilterCount = SupplierID.NullSafeLength() + LeadTime1.NullSafeLength() + LeadTime2.NullSafeLength() + SupplierCompany.NullSafeLength() + SupplierCurrencyCode.NullSafeLength() + SupplierCity.NullSafeLength() + SupplierState.NullSafeLength() + SupplierCountry.NullSafeLength(); if (requiredFilterCount != 0) { return(true); } throw new NetoRequestException("At least one filter is required in the GetSupplier request"); }
protected void btnCities_Click(object sender, EventArgs e) { Int64 SupplierId = SuppliersSessionHelper.SupplierId(); SupplierController.DeleteAllSupplierCity(SupplierId); foreach (RepeaterItem rItem in rptCity.Items) { foreach (ListItem item in ((CheckBoxList)rItem.FindControl("cblCities")).Items) { if (item.Selected == true) { SupplierCity sc = new SupplierCity(); sc.CityId = Convert.ToInt64(item.Value); sc.SupplierId = SupplierId; sc.Save(); } } } }
public JsonResult DeleteSupplierCity(SupplierCityVM ObjDelete) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); ObjDelete.CompanyID = UserInfo.fCompanyId; var SupplierCityObj = new SupplierCity(); SupplierCityObj.CompanyID = UserInfo.fCompanyId; SupplierCityObj.SupplierCityID = ObjDelete.SupplierCityID; if (!ModelState.IsValid) { string Err = " "; var errors = ModelState.Values.SelectMany(v => v.Errors); foreach (ModelError error in errors) { Err = Err + error.ErrorMessage + " * "; } Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + Err; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } _unitOfWork.SupplierCity.Delete(SupplierCityObj); _unitOfWork.Complete(); Msg.Code = 1; Msg.Msg = Resources.Resource.DeletedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
public void Add(SupplierCity ObjSave) { _context.SupplierCitys.Add(ObjSave); }