public IHttpActionResult InsertBeatMaster(BeatMasterModel BeatMaster) { InventoryClass obj = new InventoryClass(); obj.InsertBeatMaster(BeatMaster); return(Created(new Uri(Request.RequestUri + ""), "Beat Master entry created")); }
public IHttpActionResult UpdateBeat(BeatMasterModel beat) { InventoryClass obj = new InventoryClass(); obj.UpdateBeatMaster(beat); return(Created(new Uri(Request.RequestUri + ""), "Beat Master Updated")); }
/// <summary> /// This method is used to update the particular beat information, who is select from dropdownlist. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Edit1_Click(object sender, System.EventArgs e) { BeatMasterModel beat = new BeatMasterModel(); try { string cty = DropBeatNo.SelectedItem.Value; string[] arr = cty.Split(new char[] { ':' }, cty.Length); beat.City = txtCity.Text; beat.State = txtState.Text; beat.Country = txtCountry.Text; beat.BeatNo = arr[0]; using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseUri); var myContent = JsonConvert.SerializeObject(beat); var buffer = System.Text.Encoding.UTF8.GetBytes(myContent); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsync("api/BeatMasterEntryController/UpdateBeat", byteContent).Result; if (response.IsSuccessStatusCode) { string responseString = response.Content.ReadAsStringAsync().Result; var rr = Newtonsoft.Json.JsonConvert.DeserializeObject <string>(responseString); } else { response.EnsureSuccessStatusCode(); } } MessageBox.Show("Beat Updated"); Clear(); DropBeatNo.Visible = false; lblBeatNo.Visible = true; Edit1.Visible = false; btnEdit.Visible = true; checkPrevileges(); CreateLogFiles.ErrorLog("Form:BeatMasterEntery.aspx ,method Edit1_Click," + " Beat no " + arr[0] + "City Updated to " + beat.City + " user:"******"Form:BeatMasterEntery.aspx ,method Edit1_Click," + ex.Message + " user:"******"../../Sysitem/ErrorPage.aspx", false); } }
public IHttpActionResult GetSelectedBeat(string BeatNo) { InventoryClass obj = new InventoryClass(); SqlDataReader SqlDtr; string sql; BeatMasterModel beat = new BeatMasterModel(); sql = "Select * from Beat_Master where Beat_No='" + BeatNo + "'"; SqlDtr = obj.GetRecordSet(sql); while (SqlDtr.Read()) { beat.City = SqlDtr.GetValue(1).ToString(); beat.State = SqlDtr.GetValue(2).ToString(); beat.Country = SqlDtr.GetValue(3).ToString(); } SqlDtr.Close(); return(Ok(beat)); }
/// <summary> /// This method fetch the beat related information and put into the textboxes. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DropBeatNo_SelectedIndexChanged(object sender, System.EventArgs e) { try { if (DropBeatNo.SelectedIndex == 0) { return; } string cty = DropBeatNo.SelectedItem.Value; string[] arr = cty.Split(new char[] { ':' }, cty.Length); BeatMasterModel beat = new BeatMasterModel(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseUri); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var Res = client.GetAsync("api/BeatMasterEntryController/GetSelectedBeat?BeatNo=" + arr[0]).Result; if (Res.IsSuccessStatusCode) { var disc = Res.Content.ReadAsStringAsync().Result; beat = JsonConvert.DeserializeObject <BeatMasterModel>(disc); } else { Res.EnsureSuccessStatusCode(); } } if (beat != null) { txtCity.Text = beat.City; txtState.Text = beat.State; txtCountry.Text = beat.Country; } CreateLogFiles.ErrorLog("Form:BeatMasterEntery.aspx,Method:DropBeatNo_SelectedIndexChanged" + uid); } catch (Exception ex) { CreateLogFiles.ErrorLog("Form:BeatMasterEntery.aspx,Method:DropBeatNo_SelectedIndexChange" + " EXCEPTION " + ex.Message + uid); Response.Redirect("../../Sysitem/ErrorPage.aspx", false); } }
/// <summary> /// This is to Save the beat information. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, System.EventArgs e) { try { int flag = 0; using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseUri); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var Res = client.GetAsync("api/BeatMasterEntryController/FetchCity?City=" + txtCity.Text).Result; if (Res.IsSuccessStatusCode) { var disc = Res.Content.ReadAsStringAsync().Result; flag = JsonConvert.DeserializeObject <int>(disc); } else { Res.EnsureSuccessStatusCode(); } } if (DropBeatNo.Visible == false) { BeatMasterModel beatmaster = new BeatMasterModel(); beatmaster.City = StringUtil.FirstCharUpper(txtCity.Text.ToString()); beatmaster.State = StringUtil.FirstCharUpper(txtState.Text.ToString()); beatmaster.Country = StringUtil.FirstCharUpper(txtCountry.Text.ToString()); beatmaster.BeatNo = lblBeatNo.Text; using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseUri); var myContent = JsonConvert.SerializeObject(beatmaster); var buffer = System.Text.Encoding.UTF8.GetBytes(myContent); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsync("api/BeatMasterEntryController/InsertBeatMaster", byteContent).Result; if (response.IsSuccessStatusCode) { string responseString = response.Content.ReadAsStringAsync().Result; var rr = Newtonsoft.Json.JsonConvert.DeserializeObject <string>(responseString); } else { response.EnsureSuccessStatusCode(); } } CreateLogFiles.ErrorLog("Form:BeatMasterEntery.aspx,Method: btnSave_Click" + " Beatno " + beatmaster.BeatNo + " city " + beatmaster.City + " state " + beatmaster.State + " Country" + beatmaster.Country + " IS SAVED " + " userid " + uid); FillID(); lblBeatNo.Visible = true; DropBeatNo.Visible = false; MessageBox.Show("Beat details Saved"); Clear(); } else if (DropBeatNo.Visible == true && DropBeatNo.SelectedIndex == 0) { MessageBox.Show("Please select the Beat Number to Edit"); } if (flag == 1) { RMG.MessageBox.Show("City already Exits"); } checkPrevileges(); } catch (Exception ex) { CreateLogFiles.ErrorLog("Form:BeatMasterEntery.aspx,Method: btnSave_Click" + ex.Message + " userid " + uid); Response.Redirect("../../Sysitem/ErrorPage.aspx", false); } }