protected void lnkbtnNew_OnClick(object sender, EventArgs e) { if (Convert.ToString(Hidrowid.Value) == "") { this.ClearItems(); ViewState["dt"] = dtTemp = null; this.BindGridT(); } else { this.ClearItems(); this.BindCityDropDown(); } DdlFromCty.Focus(); }
private void BindCityDropDown() { TrackingDAL obj = new TrackingDAL(); var ToCity = obj.BindAllToCity(); obj = null; DdlFromCty.DataSource = ToCity; DdlFromCty.DataTextField = "city_name"; DdlFromCty.DataValueField = "city_idno"; DdlFromCty.DataBind(); DdlFromCty.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0")); DdlToCty.DataSource = ToCity; DdlToCty.DataTextField = "city_name"; DdlToCty.DataValueField = "city_idno"; DdlToCty.DataBind(); DdlToCty.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0")); }
protected void lnkbtnSubmit_OnClick(object sender, EventArgs e) { if (DdlVehicleNo.SelectedValue == "0") { ShowMessage("Please Select Vehicle No."); DdlVehicleNo.Focus(); return; } if (DdlLane.SelectedValue == "0") { ShowMessage("Please Select Lane."); DdlLane.Focus(); return; } if (DdlFromCity.SelectedValue == "0") { ShowMessage("Please Enter from City."); DdlFromCity.Focus(); return; } if (DdlToCity.SelectedValue == "0") { ShowMessage("Please Enter To City."); DdlToCity.Focus(); return; } if (DdlFromLoc.SelectedValue == "0") { ShowMessage("Please Enter From Location."); DdlFromLoc.Focus(); return; } if (DdlCompName.SelectedValue == "0") { ShowMessage("Please Enter Company Name."); DdlCompName.Focus(); return; } if (DdlFromCty.SelectedValue == "0") { ShowMessage("Please Enter from City."); DdlFromCty.Focus(); return; } if (DdlToCty.SelectedValue == "0") { ShowMessage("Please Enter To City."); DdlToCty.Focus(); return; } if (txtLeg.Text == "") { ShowMessage("Leg should be greater than zero."); txtLeg.Focus(); return; } if (txtETA.Text == "" || txtETA.Text == "0:00") { ShowMessage("ETA should be greater than zero."); txtETA.Focus(); return; } if (txtATA.Text == "" || txtATA.Text == "0:00") { ShowMessage("ATA should be greater than zero."); txtATA.Focus(); return; } if (txtETD.Text == "" || txtETD.Text == "0:00") { ShowMessage("ETD should be greater than zero."); txtETD.Focus(); return; } if (txtATD.Text == "" || txtATD.Text == "0:00") { ShowMessage("ATD should be greater than zero."); txtATD.Focus(); return; } if (txtTAThrs.Text == "" || txtTAThrs.Text == "0:00") { ShowMessage("TAT In Hrs should be greater than zero."); txtTAThrs.Focus(); return; } if (Txtdelayhrs.Text == "" || Txtdelayhrs.Text == "0:00") { ShowMessage("Delay In Hrs should be greater than zero."); Txtdelayhrs.Focus(); return; } if (Hidrowid.Value != string.Empty) { dtTemp = (DataTable)ViewState["dt"]; foreach (DataRow dtrow in dtTemp.Rows) { if (Convert.ToString(dtrow["Id"]) == Convert.ToString(Hidrowid.Value)) { dtrow["FromCity"] = DdlFromCty.SelectedItem.Text; dtrow["ToCity"] = DdlToCty.SelectedItem.Text; dtrow["Leg"] = string.IsNullOrEmpty(txtLeg.Text.Trim()) ? "0" : (txtLeg.Text.Trim()); dtrow["ETA"] = string.IsNullOrEmpty(txtETA.Text.Trim()) ? "0" : (txtETA.Text.Trim()); dtrow["ATA"] = string.IsNullOrEmpty(txtATA.Text.Trim()) ? "0" : (txtATA.Text.Trim()); dtrow["ETD"] = string.IsNullOrEmpty(txtETD.Text.Trim()) ? "0" : (txtETD.Text.Trim()); dtrow["ATD"] = string.IsNullOrEmpty(txtATD.Text.Trim()) ? "0" : (txtATD.Text.Trim()); dtrow["TAT_in_hrs"] = string.IsNullOrEmpty(txtTAThrs.Text.Trim()) ? "0" : (txtTAThrs.Text.Trim()); dtrow["Delay_in_hrs"] = string.IsNullOrEmpty(Txtdelayhrs.Text.Trim()) ? "0" : (Txtdelayhrs.Text.Trim()); dtrow["Remarks"] = txtremark.Text; dtrow["FromCityIdno"] = string.IsNullOrEmpty(DdlFromCty.SelectedValue.ToString()) ? "0" : (DdlFromCty.SelectedValue.ToString()); dtrow["ToCityIdno"] = string.IsNullOrEmpty(DdlToCty.SelectedValue.ToString()) ? "0" : (DdlToCty.SelectedValue.ToString()); } } } else { dtTemp = (DataTable)ViewState["dt"]; if (dtTemp == null) { dtTemp = CreateDt(); ViewState["dt"] = dtTemp; } Int32 ROWCount = Convert.ToInt32(dtTemp.Rows.Count) - 1; int id = dtTemp.Rows.Count == 0 ? 1 : (Convert.ToInt32(dtTemp.Rows[ROWCount]["Id"])) + 1; string strFromCity = DdlFromCty.SelectedItem.Text; string strToCity = DdlToCty.SelectedItem.Text; string strLeg = string.IsNullOrEmpty(txtLeg.Text.Trim()) ? "0" : (txtLeg.Text.Trim()); string strETA = string.IsNullOrEmpty(txtETA.Text.Trim()) ? "0" : (txtETA.Text.Trim()); string strATA = string.IsNullOrEmpty(txtATA.Text.Trim()) ? "0" : (txtATA.Text.Trim()); string strETD = string.IsNullOrEmpty(txtETD.Text.Trim()) ? "0" : (txtETD.Text.Trim()); string strATD = string.IsNullOrEmpty(txtATD.Text.Trim()) ? "0" : (txtATD.Text.Trim()); string strTAThrs = string.IsNullOrEmpty(txtTAThrs.Text.Trim()) ? "0" : (txtTAThrs.Text.Trim()); string strdelayhrs = string.IsNullOrEmpty(Txtdelayhrs.Text.Trim()) ? "0" : (Txtdelayhrs.Text.Trim()); string strReamrks = txtremark.Text.Trim(); string strFromCityIdno = DdlFromCty.SelectedValue; string strToCityIdno = DdlToCty.SelectedValue; ApplicationFunction.DatatableAddRow(dtTemp, id, strFromCity, strToCity, strLeg, strETA, strATA, strETD, strATD, strTAThrs, strdelayhrs, strReamrks, strFromCityIdno, strToCityIdno); ViewState["dt"] = dtTemp; } this.BindGridT(); ClearItems(); BindCityDropDown(); }