protected void ddlSystemParams_SelectedIndexChanged(object sender, EventArgs e) { Int32 paramid = 0; string paramid_str = ddlSystemParams.SelectedItem.Value; try { if (paramid_str != string.Empty) { paramid = Int32.Parse(paramid_str); } SystemParamsDAO sydao = new SystemParamsDAO(); string paramtyp = sydao.Get_param_type(paramid); txtParmType.Text = paramtyp; string paramval = sydao.Get_param_value(paramid); txtParamValue.Text = paramval; } catch (Exception ex) { HandleError(ex.Message, 1); } }
protected void CagesRadGrid_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { int numOfCages = (int)((RadNumericTextBox)(e.Item.FindControl("numcages_radnumerictextbox"))).Value; string cageType = ((RadComboBox)e.Item.FindControl("cagetype_radcombobox")).SelectedValue; string createForStores = ((RadioButtonList)e.Item.FindControl("rblCreateForStores")).SelectedValue; bool storesFound = false; if (createForStores == "T") { CageDAO cagedao = new CageDAO(); PrintService ps = new PrintService(); SystemParamsDAO sysParam = new SystemParamsDAO(); const Int32 toteDelayParamId = 24; const int labelsInBatch = 50; const int defaultDelay = 50; int delayCounter = 0; int delaySeconds; try { if (!int.TryParse(sysParam.Get_param_value(toteDelayParamId), out delaySeconds)) { delaySeconds = defaultDelay; // if param not set then use default delay. } } catch // The params package doesn't handle parameter not found so need to catch error. { delaySeconds = defaultDelay; // if param not set then use default delay. } // Creating IDataReader in a using block should tidy up properly when we are finished with it or // in case of failure. using (IDataReader toteLabels = cagedao.GetToteLabels(numOfCages, cageType, User.Identity.Name)) { while (toteLabels.Read()) { storesFound = true; ps.PrintPackDocuments(Convert.ToDecimal(toteLabels["order_id"].ToString()), true, Shared.UserHostName, "L", Shared.CurrentUser); delayCounter++; if (delayCounter == labelsInBatch) { System.Threading.Thread.Sleep(delaySeconds * 1000); // Sleep is in milliseconds delayCounter = 0; } } } if (storesFound) { DisplayMessage(false, "Tote Label(s) of type " + cageType + " created"); } else { DisplayMessage(true, "Error: No valid stores for tote labels found for cage type " + cageType); } } else { DoCageCreate(cageType, numOfCages); DisplayMessage(false, numOfCages.ToString() + " cage(s) of type " + cageType + " created"); } }