/// <summary> /// 停止优化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnStop_Click(object sender, EventArgs e) { thread.Abort(); Application.Lock(); if (Application["ExecuteUser"] != null) { BatchDal batchDal = new BatchDal(); batchDal.SaveExecuter("0", "0", Session["OrderDate"].ToString(), Convert.ToInt32(Session["BatchNo"])); schedule.ClearSchedule(Session["OrderDate"].ToString(), Convert.ToInt32(Session["BatchNo"])); Application.Remove("ExecuteUser"); Application.Remove("ExecuteIP"); Session.Remove("OrderDate"); Session.Remove("BatchNo"); } Application.UnLock(); JScript.Instance.RegisterScript(this, "post=false"); Session.Remove("OptimizeStatus"); btnStart.Enabled = true; btnExit.Enabled = true; btnStop.Enabled = false; }
protected void btnUpdate_Click(object sender, EventArgs e) { //保存修改到数据库 BatchDal batchDal = new BatchDal(); batchDal.Save(txtOrderDate.Text, txtSortBatch.Text, txtNO1Batch.Text, DDLNo1State.SelectedValue.ToString()); JScript.Instance.ShowMessage(UpdatePanel1, "保存数据成功。"); }
protected void lnkBtnGetBatchNo_Click(object sender, EventArgs e) { BatchDal batchDal = new BatchDal(); ddlBatchNo.DataSource = batchDal.GetBatchNo(txtOrderDate.Text); ddlBatchNo.DataTextField = "BATCHNO"; ddlBatchNo.DataValueField = "BATCHNO"; ddlBatchNo.DataBind(); }
private void BindData() { pager.PageSize = PagingSize; BatchDal batchDal = new BatchDal(); string filter = null; if (ViewState["Filter"] != null) { filter = ViewState["Filter"].ToString(); } pager.RecordCount = batchDal.GetCount(filter); DataTable batchTable = batchDal.GetAll(pageIndex, PagingSize, filter); BindTable2GridView(gvMain, batchTable); }
/// <summary> /// 数据优化后清理优化过程中的变量 /// </summary> private void AfterOptimize() { BatchDal batchDal = new BatchDal(); batchDal.SaveExecuter(Session["G_user"].ToString(), Session["Client_IP"].ToString(), Session["OrderDate"].ToString(), Convert.ToInt32(Session["BatchNo"])); Thread.Sleep(1000); Session.Remove("OptimizeStatus"); Application.Lock(); if (Application["ExecuteUser"] != null) { Application.Remove("ExecuteUser"); Application.Remove("ExecuteIP"); Session.Remove("OrderDate"); Session.Remove("BatchNo"); } Application.UnLock(); }
/// <summary> /// 获取指定日期的所有分拣批次 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnkBtnGetBatchNo_Click(object sender, EventArgs e) { BatchDal batchDal = new BatchDal(); ddlBatchNo.Items.Clear(); DataTable table = batchDal.GetBatchNo(txtOrderDate.Text); bool hasNoSchedul = false; foreach (DataRow row in table.Rows) { ddlBatchNo.Items.Add(new ListItem(row["BATCHNO"].ToString().Trim())); if (row["ISVALID"].ToString() == "0") { hasNoSchedul = true; } } if (!hasNoSchedul) { batchDal.AddBatch(txtOrderDate.Text, table.Rows.Count + 1); ddlBatchNo.Items.Add(new ListItem(Convert.ToString(table.Rows.Count + 1), "0")); } }
/// <summary> /// 开始下载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnStart_Click(object sender, EventArgs e) { if (txtOrderDate.Text.Trim().Length != 0) { ParameterDal pDal = new ParameterDal(); pDal.UpdateParameter(ddlInterface.SelectedValue.ToString(), "SALESSYSTEMDBTYPE"); int batchNo = Convert.ToInt32(ddlBatchNo.SelectedItem.Text); bool canOptimize = false; BatchDal batchDal = new BatchDal(); DataTable batchTable = batchDal.GetBatch(txtOrderDate.Text, batchNo); if (batchTable.Rows[0]["ISVALID"].ToString().Trim() == "0") { Application.Lock(); if (Application["ExecuteUser"] == null || (Application["ExecuteUser"].ToString() == Session["G_user"].ToString() && Application["ExecuteIP"].ToString() == Session["Client_IP"].ToString())) { Application["ExecuteUser"] = Session["G_user"]; Application["ExecuteIP"] = Session["Client_IP"]; Session["OrderDate"] = txtOrderDate.Text; Session["BatchNo"] = batchNo; Session["DataBase"] = ddlInterface.SelectedItem.Text; batchDal.SaveExecuter(Session["G_user"].ToString(), Session["Client_IP"].ToString(), txtOrderDate.Text, batchNo); canOptimize = true; } Application.UnLock(); if (canOptimize) { btnStart.Enabled = false; btnExit.Enabled = false; btnStop.Enabled = true; ProcessState.InProcessing = true; ProcessState.Status = "START"; JScript.Instance.RegisterScript(this, "post=true;"); ParameterDal parameterDal = new ParameterDal(); Dictionary <string, string> parameters = parameterDal.FindParameter(); if (parameters["OptimizAllOrder"] == "1")//如果优化所有数据,则在下载数据和数据优化之间不需要用户进行数据选择 { // thread = new Thread(new ThreadStart(OptimizeAll)); } else//下载数据后由用户选择需要对哪几条线路进行数据优化,所以先只下载数据而不进行数据优化 { thread = new Thread(new ThreadStart(Download)); } thread.Start(); } else { JScript.Instance.ShowMessage(Page, string.Format("用户'{0}'在机器'{1}'上做优化操作,请稍候。", Application["ExecuteUser"], Application["ExecuteIP"])); } } else { JScript.Instance.ShowMessage(Page, "该批数据已优化,请选择未优化批次。"); } } else { JScript.Instance.ShowMessage(Page, "请选择日期。"); } }
/// <summary> /// 更新上传批次状态 /// </summary> /// <param name="orderDate"></param> /// <param name="batchNo"></param> private void SaveUploadStatus(string orderDate, int batchNo) { BatchDal batchDal = new BatchDal(); batchDal.SaveUploadUser(ProcessState.UserName, orderDate, batchNo); }