Example #1
0
 public void Add(Village village)
 {
     using (DefaultCS db = new DefaultCS())
     {
         db.Villages.MergeOption = MergeOption.NoTracking;
         db.Villages.AddObject(village);
         db.SaveChanges();
     }
 }
Example #2
0
 public void Update(Village village)
 {
     using (DefaultCS db = new DefaultCS())
     {
         var d = db.Villages.Where(i => i.Id == village.Id).First();
         d.VillageName = village.VillageName;
         d.TehsilId = village.TehsilId;
         db.SaveChanges();
     }
 }
Example #3
0
 /// <summary>
 /// Create a new Village object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="tehsilId">Initial value of the TehsilId property.</param>
 /// <param name="villageName">Initial value of the VillageName property.</param>
 public static Village CreateVillage(global::System.Int32 id, global::System.Int32 tehsilId, global::System.String villageName)
 {
     Village village = new Village();
     village.Id = id;
     village.TehsilId = tehsilId;
     village.VillageName = villageName;
     return village;
 }
Example #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Villages EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToVillages(Village village)
 {
     base.AddObject("Villages", village);
 }
Example #5
0
 protected void ibAdd_Click(object sender, ImageClickEventArgs e)
 {
     GridViewRow namingContainer = (GridViewRow)((ImageButton)sender).NamingContainer;
     string text = ((TextBox)namingContainer.FindControl("txtName")).Text;
     Convert.ToInt32(((DropDownList)namingContainer.FindControl("ddlDistrict")).SelectedValue);
     int num = Convert.ToInt32(((DropDownList)namingContainer.FindControl("ddlTehsil")).SelectedValue);
     Village village = new Village()
     {
         VillageName = text,
         TehsilId = num,
         BlockId = new int?(int.Parse(base.Request["Code"]))
     };
     try
     {
         this.vMethods.Add(village);
         this.BindGrid();
         js.ShowAlert(this, "Village created succesfully!");
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (!exception.InnerException.InnerException.Message.Contains("UNIQUE"))
         {
             js.ShowAlert(this, exception.Message);
         }
         else
         {
             js.ShowAlert(this, "Village already exists! Please try another name.");
         }
     }
 }
Example #6
0
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     int rowIndex = e.RowIndex;
     string text = ((TextBox)this.GridView1.Rows[rowIndex].FindControl("txtName")).Text;
     GridViewRow item = this.GridView1.Rows[e.RowIndex];
     HiddenField hiddenField = (HiddenField)item.FindControl("lblId");
     int num = Convert.ToInt32(hiddenField.Value);
     DropDownList dropDownList = item.FindControl("ddlTehsill") as DropDownList;
     int num1 = Convert.ToInt32(base.Request["Code"]);
     int num2 = Convert.ToInt32(dropDownList.SelectedValue);
     Village village = new Village()
     {
         Id = num,
         VillageName = text,
         BlockId = new int?(num1),
         TehsilId = num2
     };
     try
     {
         this.vMethods.Update(village);
         this.GridView1.EditIndex = -1;
         this.BindGrid();
         js.ShowAlert(this, "Record updated succesfully!");
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (!exception.InnerException.InnerException.Message.Contains("UNIQUE"))
         {
             js.ShowAlert(this, exception.Message);
         }
         else
         {
             js.ShowAlert(this, "Record already exists! Please try another name.");
         }
     }
 }
Example #7
0
 public int InsertVillage(Village village)
 {
     using (DefaultCS db = new DefaultCS())
     {
         db.Villages.MergeOption = MergeOption.NoTracking;
         db.Villages.AddObject(village);
         db.SaveChanges();
         return village.Id;
     }
 }