protected void BtnSave_Click(object sender, EventArgs e) { try { if (ddlCountry.SelectedValue == null) { //LblMsg.Text = "Select Country Code...."; ddlCountry.Focus(); return; } if (TxtStateName.Text.Length == 0) { //LblMsg.Text = "State Name Is Blank, Enter Valid State Value...."; TxtStateName.Focus(); return; } BLayer.StateName = TxtStateName.Text; BLayer.CountryId = int.Parse(ddlCountry.SelectedValue); StrSql = new StringBuilder(); StrSql.Length = 0; StrSql.AppendLine("Insert Into State_Mast (StateName,CountryId,Entry_Date,Entry_Time,Entry_UID,UpdFlag) "); StrSql.AppendLine("Values (@StateName"); StrSql.AppendLine(",@CountryId"); StrSql.AppendLine(",GetDate()"); StrSql.AppendLine(",Convert(VarChar,GetDate(),108)"); StrSql.AppendLine(",@UID"); StrSql.AppendLine(",0)"); Cmd = new SqlCommand(StrSql.ToString(), SqlFunc.gConn); Cmd.Parameters.AddWithValue("@StateName", BLayer.StateName); Cmd.Parameters.AddWithValue("@CountryId", BLayer.CountryId); Cmd.Parameters.AddWithValue("@UID", HidFldUID.Value.ToString()); SqlFunc.ExecuteNonQuery(Cmd); FillGrid(); ddlCountry.SelectedIndex = -1; TxtStateName.Text = ""; ddlCountry.Focus(); LblMsg.Text = "Entry Insert Successfully..."; } catch (Exception ex) { Response.Write(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack == false) { TxtStateName.Focus(); this.Form.DefaultButton = BtnGo.UniqueID; LblMessage.Text = Request.QueryString["Message"]; DataTable ObjCountryTable = MyJobPortalModel.Country.GetCountryRecords("status='Active'"); DdlCountry.DataSource = ObjCountryTable; DdlCountry.DataBind(); DdlCountry.Items.Insert(0, new ListItem("--Select--", "--Select--")); ShowGridView(); } }
protected void BtnUpdateState_Click(object sender, EventArgs e) { if (this.IsValid == true) { if ((int)MyJobPortalModel.State.GetStateRecords("StateName='" + TxtStateNameEdit.Text + "' and Id<>" + HdnStateId.Value).Rows.Count > 0) { LblDuplicateStateNameErrorEdit.Visible = true; return; } else { MyJobPortalModel.State ObjState = new MyJobPortalModel.State(int.Parse(HdnStateId.Value)); ObjState.StateName = TxtStateNameEdit.Text; ObjState.CountryId = int.Parse(DdlCountryEdit.SelectedValue); ObjState.Status = DdlStatusEdit.SelectedValue; ObjState.Update(); EditStateModal.Visible = false; TxtStateName.Focus(); this.Form.DefaultButton = BtnGo.UniqueID; LblMessage.Text = TxtStateNameEdit.Text + " has been updated"; ShowGridView(); } } }
protected void LnkBtnCloseState_Click(object sender, EventArgs e) { EditStateModal.Visible = false; TxtStateName.Focus(); this.Form.DefaultButton = BtnGo.UniqueID; }