protected void LocalBtn_Click(object sender, EventArgs e) { var No = (TextBox)FormEdit.FindControl("Queue_NoTxt"); var Registration = (TextBox)FormEdit.FindControl("RegistrationLocal"); var Trailer = (TextBox)FormEdit.FindControl("TextTRAILER_TEXT"); var LONO = (TextBox)FormEdit.FindControl("LONOLocal"); var MSP = (TextBox)FormEdit.FindControl("MSPtxt"); var AGO = (TextBox)FormEdit.FindControl("AGOtxt"); var KERO = (TextBox)FormEdit.FindControl("KEROtxt"); var JET = (TextBox)FormEdit.FindControl("JETtxt"); var id = Convert.ToInt32(Request.QueryString["id"]); var updateStatus = "UPDATE NewQueue SET Queue_No = @Queue_No, Registration = @Registration, TRAILER_TEXT = @TRAILER_TEXT, LO_NO = @LO_NO, MSP = @MSP, AGO = @AGO, KERO = @KERO, JET = @JET WHERE ID = @ID"; using (var myConnection = new SqlConnection(strConnection)) { myConnection.Open(); var myCommand = new SqlCommand(updateStatus, myConnection); myCommand.Parameters.AddWithValue("@Queue_No", No.Text); myCommand.Parameters.AddWithValue("@Registration", Registration.Text); myCommand.Parameters.AddWithValue("@TRAILER_TEXT", Trailer.Text); myCommand.Parameters.AddWithValue("@LO_NO", LONO.Text); myCommand.Parameters.AddWithValue("@MSP", MSP.Text); myCommand.Parameters.AddWithValue("@AGO", AGO.Text); myCommand.Parameters.AddWithValue("@KERO", KERO.Text); myCommand.Parameters.AddWithValue("@JET", JET.Text); myCommand.Parameters.AddWithValue("@ID", id); myCommand.ExecuteNonQuery(); myConnection.Close(); } var Type = (Label)FormEdit.FindControl("Type"); var Shipper = (Label)FormEdit.FindControl("Shipper"); var QueueID = (Label)FormEdit.FindControl("QueueID"); //save to log var changeTime = DateTime.Now; var companyNo = User.Identity.Name; var updateRecord = "INSERT INTO Pipecor_Edit(CompNumber, TimeOfEdit, Type, TruckGuidModified, QueueNo, Shipper, Registration, LO_NO) VALUES (@CompNumber, @TimeOfEdit, @Type, @TruckGuidModified, @QueueNo, @Shipper, @Registration, @LO_NO)"; using (var myConnection = new SqlConnection(strConnection)) { myConnection.Open(); var myCommand = new SqlCommand(updateRecord, myConnection); myCommand.Parameters.AddWithValue("@CompNumber", companyNo); myCommand.Parameters.AddWithValue("@TimeOfEdit", changeTime); myCommand.Parameters.AddWithValue("@Type", Type.Text); myCommand.Parameters.AddWithValue("@TruckGuidModified", QueueID.Text); myCommand.Parameters.AddWithValue("@QueueNo", No.Text); myCommand.Parameters.AddWithValue("@Shipper", Shipper.Text); myCommand.Parameters.AddWithValue("@Registration", Registration.Text); myCommand.Parameters.AddWithValue("@LO_NO", LONO.Text); myCommand.ExecuteNonQuery(); myConnection.Close(); } Response.Redirect("EditDetail.aspx?status=ok&ID=" + id); }
private void QueueOrder(object sender, string type, int total, string shipperList, string driverList) { if (IsPostBack) { var conSAP = new SqlConnection(strConnection); var cmd = new SqlCommand(); //Label lblSAPid = (Label)grdRow.FindControl("SAP_ID"); var Registration = (TextBox)FormEdit.FindControl("RegistrationLocal"); var LO_NO = (TextBox)FormEdit.FindControl("LONOLocal"); var MSP = (TextBox)FormEdit.FindControl("MSPtxt"); var AGO = (TextBox)FormEdit.FindControl("AGOtxt"); var KERO = (TextBox)FormEdit.FindControl("KEROtxt"); var JET = (TextBox)FormEdit.FindControl("JETtxt"); var No = (TextBox)FormEdit.FindControl("Notxt"); var TrailerNo = (TextBox)FormEdit.FindControl("TRAILER_TEXT"); //TextBox txtNo = (TextBox)grdRow.FindControl("txtNo"); total = total + 1; var named = User.Identity.Name; var newQueueId = Guid.NewGuid().ToString(); var statusTime = DateTime.Now; var setDate = DateTime.Today; try { var query = "INSERT INTO NewQueue([Queue_No],[Shipper],[Registration],[Type],[LO_NO],[MSP],[AGO],[KERO],[JET],[Status],[QueueID],[EnterName],[SetDate],[StatusTime],[DRIVER_NUMBER],[TRAILER_TEXT]) values('" + No.Text + "','" + shipperList.Trim() + "','" + Registration.Text.ToUpper() + "','" + type + "','" + LO_NO.Text.ToUpper() + "','" + MSP.Text + "','" + AGO.Text + "','" + KERO.Text + "','" + JET.Text + "','SECTA','" + newQueueId + "','" + named + "','" + setDate + "','" + statusTime + "','" + driverList + "','" + TrailerNo.Text.ToUpper() + "');"; var objda = new SqlDataAdapter(query, objcon); objcon.Open(); objda.SelectCommand.ExecuteNonQuery(); objcon.Close(); //add unique guid to all tables AddGuidToTables(newQueueId); //then sap status //UpdateSAP(conSAP, cmd, lblSAPid); } catch (SqlException ex) { var errorMsg = "Error in Updation"; errorMsg += ex.Message; throw new Exception(errorMsg); } finally { conSAP.Close(); } } }
protected void LocalBtn_Click(object sender, EventArgs e) { if (Page.IsPostBack) { var localTotal = GridTotalLocal.Rows.Count; var exportTotal = GridTotalExport.Rows.Count; var typeList = (DropDownList)FormEdit.FindControl("ddlType"); var shipperList = (DropDownList)FormEdit.FindControl("ddlShipper"); var driverList = (DropDownList)FormEdit.FindControl("ddlDriver"); var No = (TextBox)FormEdit.FindControl("Notxt"); var EnterNo = Convert.ToInt32(No.Text); var totalNo = EnterNo; if (typeList.SelectedValue == "LOCAL") { //if (totalNo > localTotal) //{ QueueOrder(sender, "LOCAL", localTotal, shipperList.SelectedValue.Trim(), driverList.SelectedValue.Trim()); //} //else //{ // Response.Redirect("QueueAdd.aspx?status=err&no=" + EnterNo + "&type=local"); //} } else if (typeList.SelectedValue == "EXPORT") { //if (totalNo > exportTotal) //{ QueueOrder(sender, "EXPORT", exportTotal, shipperList.SelectedValue.Trim(), driverList.SelectedValue.Trim()); //} //else //{ // Response.Redirect("QueueAdd.aspx?status=err&no=" + EnterNo + "&type=export"); //} } Response.Redirect("QueueAdd.aspx?status=ok&type=" + typeList.SelectedValue.ToLower()); } }
private void SetDropDown() { var shipperList = (DropDownList)FormEdit.FindControl("ddlShipper"); var driverList = (DropDownList)FormEdit.FindControl("ddlDriver"); var con = new SqlConnection(strConnection); //shipper var comShipper = "Select Shipper_Name, Shipper_Code from SAP_Shippers Order By Shipper_Name"; var adptShipper = new SqlDataAdapter(comShipper, con); var dtShipper = new DataTable(); adptShipper.Fill(dtShipper); var rowShipper = dtShipper.NewRow(); rowShipper["Shipper_Name"] = ""; dtShipper.Rows.InsertAt(rowShipper, 0); shipperList.DataSource = dtShipper; shipperList.DataBind(); shipperList.DataTextField = "Shipper_Name"; shipperList.DataValueField = "Shipper_Code"; shipperList.DataBind(); //drivers var comDrivers = "Select DRIVER_NUMBER, NAME from PS28drivers Order By NAME"; var adptDrivers = new SqlDataAdapter(comDrivers, con); var dtDrivers = new DataTable(); adptDrivers.Fill(dtDrivers); var row = dtDrivers.NewRow(); row["NAME"] = ""; dtDrivers.Rows.InsertAt(row, 0); driverList.DataSource = dtDrivers; driverList.DataBind(); driverList.DataTextField = "NAME"; driverList.DataValueField = "DRIVER_NUMBER"; driverList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { SqlEditSource.SelectParameters["TheDate"].DefaultValue = DateTime.Today.ToString(); var resulting = Request.QueryString["STATUS"]; var theID = Request.QueryString["id"]; if (resulting == "ok") { ClientScript.RegisterStartupScript(GetType(), "startup", "<script type=\"text/javascript\">CheckTruck();</script>"); lblPopUp.Text = "Order edited successfully"; } var type = (Label)FormEdit.FindControl("LabelType"); var LocalTable = (Panel)FormEdit.FindControl("LocalTable"); var ExportTable = (Panel)FormEdit.FindControl("ExportTable"); if (string.IsNullOrEmpty(theID)) { Response.Redirect("QueueEdit.aspx"); } else { try { if (type.Text == "Export") { LocalTable.Visible = false; } else if (type.Text == "Local") { ExportTable.Visible = false; } } catch { Response.Redirect("QueueEdit.aspx"); } } var lblEditable_No = (Label)View.FindControl("lblEditable_No"); var lblEditable_Reg = (Label)View.FindControl("lblEditable_Reg"); var Editable_LONO = (Label)View.FindControl("Editable_LONO"); var lblEditable_Quantity = (Label)View.FindControl("lblEditable_Quantity"); var lblEditable_Product = (Label)View.FindControl("lblEditable_Product"); var NoExport = (TextBox)FormEdit.FindControl("Queue_NoExport"); var NoLocal = (TextBox)FormEdit.FindControl("Queue_NoTxt"); var RegistrationExport = (TextBox)FormEdit.FindControl("RegistrationExport"); var RegistrationLocal = (TextBox)FormEdit.FindControl("RegistrationLocal"); var LONOTExport = (TextBox)FormEdit.FindControl("LONOTExport"); var LONOLocal = (TextBox)FormEdit.FindControl("LONOLocal"); var Quantity = (TextBox)FormEdit.FindControl("QuantityTxt"); var Product = (TextBox)FormEdit.FindControl("ProductTxt"); var MSP = (TextBox)FormEdit.FindControl("MSPtxt"); var AGO = (TextBox)FormEdit.FindControl("AGOtxt"); var KERO = (TextBox)FormEdit.FindControl("KEROtxt"); var JET = (TextBox)FormEdit.FindControl("JETtxt"); //check editable if (lblEditable_No.Text == "False") { NoLocal.ReadOnly = true; NoLocal.Enabled = false; } if (lblEditable_Reg.Text == "False") { RegistrationLocal.ReadOnly = true; RegistrationLocal.Enabled = false; } if (Editable_LONO.Text == "False") { LONOLocal.ReadOnly = true; LONOLocal.Enabled = false; } if (lblEditable_Quantity.Text == "False") { Quantity.ReadOnly = true; MSP.ReadOnly = true; AGO.ReadOnly = true; KERO.ReadOnly = true; JET.ReadOnly = true; Quantity.Enabled = false; MSP.Enabled = false; AGO.Enabled = false; KERO.Enabled = false; JET.Enabled = false; } if (lblEditable_Product.Text == "False") { Product.ReadOnly = true; Product.Enabled = false; } }