private void BindDropDown() { TrackingDAL obj = new TrackingDAL(); var ToComp = obj.BindCompany(); var ToFromLoc = obj.BindFromLoc(); var ToTruck = obj.BindLorry(); obj = null; DdlCompName.DataSource = ToComp; DdlCompName.DataTextField = "Comp_Name"; DdlCompName.DataValueField = "city_idno"; DdlCompName.DataBind(); DdlCompName.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0")); DdlFromLoc.DataSource = ToFromLoc; DdlFromLoc.DataTextField = "City_Name"; DdlFromLoc.DataValueField = "City_Idno"; DdlFromLoc.DataBind(); DdlFromLoc.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0")); DdlVehicleNo.DataSource = ToTruck; DdlVehicleNo.DataTextField = "Lorry_No"; DdlVehicleNo.DataValueField = "Lorry_Idno"; DdlVehicleNo.DataBind(); DdlVehicleNo.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0")); }
protected void lnkbtnSave_OnClick(object sender, EventArgs e) { Int64 intIdno = 0; #region Validation Messages for Tracking Details if (DdlVehicleNo.SelectedIndex == 0) { this.ShowMessage("Please Enter Vehicle No"); DdlVehicleNo.Focus(); return; } if (DdlLane.SelectedIndex == 0) { this.ShowMessage("Please select Lane"); DdlLane.Focus(); return; } if (DdlFromCity.SelectedIndex == 0) { this.ShowMessage("Please select From City"); DdlFromCity.Focus(); return; } if (DdlToCity.SelectedIndex == 0) { this.ShowMessage("Please select To City"); DdlToCity.Focus(); return; } if (DdlCompName.SelectedIndex == 0) { this.ShowMessage("Please Enter Company Name"); DdlCompName.Focus(); return; } if (DdlFromLoc.SelectedIndex == 0) { this.ShowMessage("Please Enter From Location"); DdlFromLoc.Focus(); return; } dtTemp = (DataTable)ViewState["dt"]; if (dtTemp != null) { if (dtTemp.Rows.Count <= 0) { ShowMessage("Please enter details"); return; } } if (grdMain.Rows.Count <= 0) { ShowMessage("Please enter details"); return; } #endregion Int64 trackingIdno = 0; TrackingDAL objtrackingDAL = new TrackingDAL(); if (Request.QueryString["q"] != null) { trackingIdno = Convert.ToInt64(Request.QueryString["q"]); } Int64 VehicleNo = Convert.ToInt64(DdlVehicleNo.SelectedValue); string Date = txtDate.Text; Int64 LaneIdno = Convert.ToInt64(DdlLane.SelectedValue); Int64 CompName = Convert.ToInt64(DdlCompName.SelectedValue); Int64 FromLoc = Convert.ToInt64(DdlFromLoc.SelectedValue); Int64 FromCityIdno = Convert.ToInt64(DdlFromCity.SelectedValue); Int64 ToCityIdno = Convert.ToInt64(DdlToCity.SelectedValue); DataTable dtDetail = (DataTable)ViewState["dt"]; if (this.ValidationEstNoSave((Request.QueryString["q"] != null) ? Convert.ToInt64(Request.QueryString["q"]) : 0)) // if (this.ValidationEstNoSave((Request.QueryString["q"] != null) ? Convert.ToInt64(Request.QueryString["q"]) : 0)) { using (TransactionScope dbTran = new TransactionScope(TransactionScopeOption.Required)) { try { if (grdMain.Rows.Count > 0 && dtTemp != null && dtTemp.Rows.Count > 0) { if (string.IsNullOrEmpty(hidid.Value) == false) { intIdno = objtrackingDAL.Update(trackingIdno, VehicleNo, Date, LaneIdno, FromCityIdno, ToCityIdno, CompName, FromLoc, dtDetail); } else { intIdno = objtrackingDAL.Insert(trackingIdno, VehicleNo, Date, LaneIdno, FromCityIdno, ToCityIdno, CompName, FromLoc, dtDetail); } objtrackingDAL = null; } if (intIdno > 0) { dbTran.Complete(); dbTran.Dispose(); ShowMessage("Record saved Successfully"); } else if (intIdno < 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Vehicle already made with this No.')", true); dbTran.Dispose(); } else { if (Request.QueryString["q"] != null) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record not updated.')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record(s) not saved.')", true); } dbTran.Dispose(); } Clear(); ClearItems(); BindCityDropDown(); grdMain.DataSource = null; grdMain.DataBind(); } catch (Exception exe) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Some issue occure, Please Contact Cogxim Support Executive.')", true); dbTran.Dispose(); } } } }
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(); }