protected void btnSearch_Click(object sender, EventArgs e) { cboRegion.ClearSelection(); drpWoredaRegion.ClearSelection(); drpWoredaZone.ClearSelection(); drpWoredaZone.Items.Clear(); drpZoneRegion.ClearSelection(); txtAddRegion.Text = txtAddWoreda.Text = txtAddZone.Text = string.Empty; gvWereda.DataSource = new DataTable(); gvWereda.DataBind(); gvZone.DataSource = new DataTable(); gvZone.DataBind(); if (rbZoneWoreda.SelectedValue == "1")//woreda { FillRegion(drpWoredaRegion); gvWereda.DataSource = ModelLocation.GetWoredaByName(txtLocationName.Text); gvWereda.DataBind(); } else if (rbZoneWoreda.SelectedValue == "2")//zone { FillRegion(drpZoneRegion); gvZone.DataSource = ModelLocation.GetZoneByName(txtLocationName.Text); gvZone.DataBind(); } }
void SaveWoreda(bool isNEW) { if (cboRegion.SelectedIndex <= 0) { Messages.SetMessage("Please select Region first!", WarehouseApplication.Messages.MessageType.Warning); UpdatePanel1.Update(); return; } else if (gvZone.SelectedIndex < 0) { Messages.SetMessage("Please select Zone first!", WarehouseApplication.Messages.MessageType.Warning); UpdatePanel1.Update(); return; } ModelLocation ml = new ModelLocation(); ml.ID = isNEW ? Guid.NewGuid() : new Guid(((Label)gvWereda.SelectedRow.FindControl("lblWoredaID")).Text.Trim()); ml.Description = txtAddWoreda.Text.Trim(); ml.RegionID = new Guid(cboRegion.SelectedValue); ml.ZoneID = new Guid(drpWoredaZone.SelectedValue); ml.WoredaID = ml.ID; ml.Save(); FillWorada(); Messages.SetMessage("Location successfully updated!", WarehouseApplication.Messages.MessageType.Success); UpdatePanel1.Update(); }
public ActionResult Edit(ModelLocation location, List <MultipleIngredient> ingredients) { try { if (ModelState.IsValid) { Dictionary <ModelIngredient, int> inventory = new Dictionary <ModelIngredient, int>(); foreach (var i in ingredients) { if (i.Quantity > 0) { inventory[i.Ingredient] = i.Quantity; } } location.Inventory = inventory; Repo.UpdateLocation(Mapper.Map(location)); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
protected void gvWereda_PageIndexChanging(object sender, GridViewPageEventArgs e) { gvWereda.PageIndex = e.NewPageIndex; gvWereda.DataSource = ModelLocation.GetWoreda(new Guid(((Label)gvZone.SelectedRow.FindControl("lblZoneID")).Text.Trim()) , new Guid(cboRegion.SelectedValue)); gvWereda.DataBind(); }
void FillZoneForWoreda(Guid Region) { drpWoredaZone.Items.Add(""); drpWoredaZone.DataSource = ModelLocation.GetZone(Region); drpWoredaZone.DataValueField = "ID"; drpWoredaZone.DataTextField = "Description"; drpWoredaZone.DataBind(); }
public static string GetUserVisiblePathFromModelLocation(this ModelLocation modelLocation) { if (modelLocation.Type != ModelLocationType.Server) { throw new NotSupportedException("ERROR: GetUserVisiblePathFromModelLocation cannot handle non-server ModelLocations."); } return(string.Format("{0}{1}{2}{3}", "RSN://", modelLocation.CentralServer, Path.AltDirectorySeparatorChar, modelLocation.RelativePath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar))); }
public ExportCredential(string hostId, string modelPath, string savePath) { HostIp = hostId; SavePath = savePath; ModelPath = modelPath; TempTargetFolder = GetTempTargetFolder(); UserName = GetUserName(); ModelLocation = new ModelLocation(HostIp, ModelPath, ModelLocationType.Server); }
void FillRegion(DropDownList dr) { dr.Items.Clear(); dr.Items.Add(new ListItem("- Please Select Region -", "")); dr.DataSource = ModelLocation.GetRegion(); dr.DataValueField = "ID"; dr.DataTextField = "Description"; dr.DataBind(); }
public List <ModelLocation> Get() { List <ModelLocation> lista = new List <ModelLocation>(); List <locations> dbList = db.locations.ToList(); foreach (locations loc in dbList) { ModelLocation ml = new ModelLocation(loc); lista.Add(ml); } return(lista); }
public List <ModelLocation> Get(string naziv) { List <ModelLocation> lista = new List <ModelLocation>(); List <locations> dbList = db.locations.Where(x => x.loc_name.Equals(naziv)).ToList(); foreach (locations loc in dbList) { ModelLocation ml = new ModelLocation(loc); lista.Add(ml); } return(lista); }
void SaveRegion(bool isNEW) { ModelLocation ml = new ModelLocation(); ml.ID = isNEW ? Guid.NewGuid() : new Guid(cboRegion.SelectedValue); ml.Description = txtAddRegion.Text.Trim(); ml.RegionID = ml.ID; ml.ZoneID = null; ml.WoredaID = null; ml.Save(); Messages.SetMessage("Location successfully updated!", WarehouseApplication.Messages.MessageType.Success); UpdatePanel1.Update(); FillRegion(cboRegion); txtAddRegion.Text = string.Empty; }
public List <ModelLocation> Get(int id) { List <ModelLocation> lista = new List <ModelLocation>(); locations loc = null; loc = db.locations.Find(id); if (loc != null) { ModelLocation ml = new ModelLocation(loc); lista.Add(ml); } return(lista); }
protected void btnRemoveRegion_Click(object sender, EventArgs e) { DataTable dt = ModelLocation.GetZone(new Guid(cboRegion.SelectedValue)); if (dt.Rows.Count > 0) { Messages.SetMessage("The Region contains " + dt.Rows.Count + " zone under it. Removing Region having one or more zone is not allowed!" , WarehouseApplication.Messages.MessageType.Error); UpdatePanel1.Update(); return; } ModelLocation.DeleteLocation(new Guid(cboRegion.SelectedValue)); FillRegion(cboRegion); }
protected void gvZone_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataTable dt = ModelLocation.GetWoreda(new Guid(((Label)gvZone.Rows[e.RowIndex].FindControl("lblZoneID")).Text.Trim()) , new Guid(cboRegion.SelectedValue)); if (dt.Rows.Count > 0) { Messages.SetMessage("The zone contains " + dt.Rows.Count + " worada under it. Removing a zone having one or more worada is not allowed!" , WarehouseApplication.Messages.MessageType.Error); UpdatePanel1.Update(); return; } ModelLocation.DeleteLocation(new Guid(((Label)gvZone.Rows[e.RowIndex].FindControl("lblZoneID")).Text)); FillZone(); }
void FillWorada() { gvWereda.DataSource = new DataTable(); gvWereda.DataBind(); drpWoredaZone.Items.Clear(); if (gvZone.SelectedIndex >= 0 && drpZoneRegion.SelectedIndex > 0) { gvWereda.DataSource = ModelLocation.GetWoreda(new Guid(((Label)gvZone.SelectedRow.FindControl("lblZoneID")).Text.Trim()) , new Guid(drpZoneRegion.SelectedValue)); gvWereda.DataBind(); txtAddWoreda.Text = string.Empty; FillRegion(drpWoredaRegion); FillZoneForWoreda(new Guid(drpZoneRegion.SelectedValue)); drpWoredaZone.SelectedValue = ((Label)gvZone.SelectedRow.FindControl("lblZoneID")).Text.Trim(); drpWoredaRegion.SelectedValue = drpZoneRegion.SelectedValue; } }
void FillZone() { gvZone.DataSource = new DataTable(); gvZone.DataBind(); drpZoneRegion.Items.Clear(); gvWereda.DataSource = new DataTable(); gvWereda.DataBind(); drpWoredaZone.Items.Clear(); if (cboRegion.SelectedIndex > 0) { string regionID = cboRegion.SelectedValue; Guid reID = new Guid(regionID); gvZone.DataSource = ModelLocation.GetZone(new Guid(cboRegion.SelectedValue)); gvZone.DataBind(); txtAddZone.Text = string.Empty; FillRegion(drpZoneRegion); drpZoneRegion.SelectedValue = cboRegion.SelectedValue; } }
public ModelLocation GetById(int id) { ModelLocation location = (ModelLocation)db.Location.First(i => i.Id == id); return(location); }
protected void gvWereda_RowDeleting(object sender, GridViewDeleteEventArgs e) { ModelLocation.DeleteLocation(new Guid(((Label)gvWereda.Rows[e.RowIndex].FindControl("lblWoredaID")).Text)); FillWorada(); }
public void AddNew(ModelLocation location) { db.Location.InsertOnSubmit(location); db.SubmitChanges(); }
protected void gvZone_PageIndexChanging(object sender, GridViewPageEventArgs e) { gvZone.PageIndex = e.NewPageIndex; gvZone.DataSource = ModelLocation.GetZone(new Guid(cboRegion.SelectedValue)); gvZone.DataBind(); }
public string GetById(int id) { ModelLocation location = LocationDAO.GetById(id); return(JsonHelpers.stringify(location)); }