protected void Page_Load(object sender, EventArgs e) { if (_ControlObjectContext == null) { _ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session); } WebUserControlEditOrderMaterials1.ControlObjectContext = _ControlObjectContext; if (!IsPostBack) { URLPopUpControlShowFreightData.Visible = false; DropDownListLocations.DataBind(); DropDownListCustomers.DataBind(); Common.LimitLocationList(DropDownListLocations.Items, Session, _ControlObjectContext); ShowCorrectPanels(); ShowCorrectCustomer(); ButtonRefresh_Click(sender, e); } ShowFreightButton(); }
public void UpdateDropdown() { SqlConnection conn = new SqlConnection(@"data source = CHRISTOFFER-PC; integrated security = true; database = pest_exterminators"); SqlDataAdapter da = null; DataSet ds = null; DataTable dt = null; string sqlsel = "SELECT * FROM customers"; try { // conn.Open(); SqlDataAdapter opens connection by itself da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(sqlsel, conn); ds = new DataSet(); da.Fill(ds, "CustomerList"); dt = ds.Tables["CustomerList"]; DropDownListCustomers.DataSource = dt; DropDownListCustomers.DataTextField = "customer_email"; DropDownListCustomers.DataValueField = "customer_id"; DropDownListCustomers.DataBind(); DropDownListCustomers.Items.Insert(0, "Select a Customer"); } catch (Exception ex) { LabelMessage.Text = ex.Message; } finally { conn.Close(); // SqlDataAdapter closes connection by itself; but can fail in case of errors } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GenerateDescription(); CalendarControlStart.SelectedDateTime = Common.CurrentClientDateTime(Session); CalendarControlEnd.SelectedDateTime = Common.CurrentClientDateTime(Session).AddDays(1); CheckBoxDatesOpenEndDate.Attributes.Add("onclick", "toggle(this,'MainContent_MainContent_WebUserControlRentOut1_CalendarControlEnd_TextBoxDate'); toggle(this,'MainContent_MainContent_WebUserControlRentOut1_CalendarControlEnd_ButtonSetDate');"); DropDownListCustomers.DataBind(); DropDownListLocations.DataBind(); bool CustIdSet = false; bool LocIdSet = false; bool DescSet = false; if (Request.Params["CustId"] != null) { string CustId = Request.Params["CustId"].ToString(); ListItem li = DropDownListCustomers.Items.FindByValue(CustId); if (li != null) { li.Selected = true; CustIdSet = true; } } if (Request.Params["LocId"] != null) { string LocId = Request.Params["LocId"].ToString(); ListItem li = DropDownListLocations.Items.FindByValue(LocId); if (li != null) { li.Selected = true; LocIdSet = true; } } if (Request.Params["Description"] != null) { TextBox_Description.Text = Request.Params["Description"].ToString(); DescSet = TextBox_Description.Text.Trim() != ""; } if (Request.Params["Identification"] != null) { TextBox_DriverId.Text = Request.Params["Identification"].ToString(); DescSet = TextBox_Description.Text.Trim() != ""; } if (LocIdSet && CustIdSet && DescSet) { CurrentPageNr = 2; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownListLocations.DataBind(); DropDownListCustomers.DataBind(); bool CustIdSet = false; bool LocIdSet = false; if (Request.Params["CustId"] != null) { string CustId = Request.Params["CustId"].ToString(); ListItem li = DropDownListCustomers.Items.FindByValue(CustId); if (li != null) { li.Selected = true; CustIdSet = true; } } if (Request.Params["LocId"] != null) { string LocId = Request.Params["LocId"].ToString(); ListItem li = DropDownListLocations.Items.FindByValue(LocId); if (li != null) { li.Selected = true; LocIdSet = true; } } if (LocIdSet && CustIdSet) { PageNr = 2; } } }
public void LoadFromFreight(Freight frg, bool ForceReload) { if ((LabelFreightGuid.Text != frg.Id.ToString()) || ForceReload) { ListItem li = null; FreightWeighing fgw = null; if (frg.FreightWeighing.Count > 0) { fgw = frg.FreightWeighing.First <FreightWeighing>(); } LabelOrderNr.Text = frg.OurReference.ToString(); TextBox_Description.Text = frg.Description; if (frg.FreightDirection == "To warehouse") { // switch to purchase order SwitchPurchaseType(InvoiceType.Buy); } else { // switch to sales order SwitchPurchaseType(InvoiceType.Sell); } // first load the customer, this is required for Freights DropDownListCustomers.DataBind(); li = DropDownListCustomers.Items.FindByValue(frg.FromRelation.Id.ToString()); if (li != null) { li.Selected = true; LabelCustID.Text = li.Value; } DropDownListLocations.DataBind(); li = DropDownListLocations.Items.FindByValue(frg.SourceOrDestinationLocation.Id.ToString()); if (li != null) { li.Selected = true; } DropDownListCustomerFreights.DataBind(); li = DropDownListCustomerFreights.Items.FindByValue(frg.Id.ToString()); if (li != null) { li.Selected = true; DropDownListCustomerFreights.SelectedIndex = DropDownListCustomerFreights.Items.IndexOf(li); } TextBox_YourTruckPlate.Text = frg.YourTruckPlate; TextBox_YourDriverName.Text = frg.YourDriverName; if (fgw != null) { TextBoxFreightID.Text = fgw.Description; } WebUserControlEditOrderMaterials1.LoadFromFreight(frg); LabelFreightGuid.Text = frg.Id.ToString(); } }