/// <summary> /// 審核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Check_Click(object sender, EventArgs e) { try { List <string> delproductlist = new List <string>(); var RId = ""; //組刪除產品 foreach (GridViewRow row in gv_List.Rows) { RId = GetCellByName(row, "需求單ID").Text; var 產品編號 = GetCellByName(row, "產品編號").Text; CheckBox 選擇 = GetCellByName(row, "選擇").FindControl("CB_Select") as CheckBox; if (!選擇.Checked) { delproductlist.Add(產品編號); } } //送出 var result = RequireDA.CheckRequire(RId, delproductlist, Utility.GetStore(_areaId), account); lbl_Message.Text = result.Reason; btn_Check.Enabled = result.Result == "0"; } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 查詢 /// </summary> protected void Search() { try { int status = int.Parse(DDL_Status.SelectedValue); int type = int.Parse(DDL_Type.SelectedValue); //特定需求單 var 特定需求單 = txt_特定需求單.Text.Trim(); RequireDA.RequireStatus BoxStatus = RequireDA.RequireStatus.未建傳票; RequireDA.RequireType BoxType = (type == -1) ? RequireDA.RequireType.全部 : (type == 0) ? RequireDA.RequireType.調撥 : (type == 1) ? RequireDA.RequireType.瑕疵 : RequireDA.RequireType.問題件; var temp = (特定需求單 == "") ? RequireDA.GetRequireAllStatusList(BoxStatus, BoxType, DateTime.Parse(txt_Start.Text), DateTime.Parse(txt_End.Text).AddDays(1), _areaId).Where(y => y.狀態 == 0).ToList() : RequireDA.GetRequireOneStatusList(特定需求單, _areaId); #region ●需求單狀態 int x = 1; var temp2 = (from i in temp orderby i.申請時間 descending select new { 序號 = x++, 需求單ID = i.需求單ID, 種類 = i.種類, 產品編號 = i.產品編號, 預撥數量 = i.預撥數量, 申請人 = i.申請人, 申請時間 = i.申請時間.ToString("yyyy-MM-dd HH:mm"), 審核人 = i.審核人 ?? "無", 審核時間 = i.審核時間.HasValue ? i.審核時間.Value.ToString("yyyy-MM-dd HH:mm") : "", 狀態 = (i.狀態 == -1) ? "取消" : (i.預撥數量 == 0) ? "移除" : (i.狀態 == 0) ? "待審" : (i.狀態 >= 1 && i.狀態 < 10) ? "待建傳票" : "可印單", }).ToList(); gv_List.DataSource = temp2; gv_List.DataBind(); #endregion ●需求單狀態 var 需求單數 = temp2.Select(y => y.需求單ID).Distinct().Count(); var 預撥數 = temp2.Sum(y => y.預撥數量); var 總筆數 = temp2.Count(); lbl_Count.Text = "總筆數: " + 總筆數 + ", " + "需求單數: " + 需求單數 + ", " + "預撥數: " + 預撥數; //單一需求單未審核才可審核 btn_Check.Visible = (!string.IsNullOrEmpty(特定需求單) && gv_List.Rows.Count > 0 && GetCellByName(gv_List.Rows[0], "狀態").Text == "待審"); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 查詢 /// </summary> protected void Search() { try { int status = int.Parse(DDL_Status.SelectedValue); int type = int.Parse(DDL_Type.SelectedValue); //特定需求單 var 特定需求單 = txt_特定需求單.Text.Trim(); RequireDA.RequireStatus BoxStatus = (status == -2) ? RequireDA.RequireStatus.全部 : (status == -1) ? RequireDA.RequireStatus.取消 : (status == 1) ? RequireDA.RequireStatus.未建傳票 : RequireDA.RequireStatus.已建傳票; RequireDA.RequireType BoxType = (type == -1) ? RequireDA.RequireType.全部 : (type == 0) ? RequireDA.RequireType.調撥 : (type == 1) ? RequireDA.RequireType.瑕疵 : RequireDA.RequireType.問題件; var temp = (特定需求單 == "") ? RequireDA.GetRequireAllStatusList(BoxStatus, BoxType, DateTime.Parse(txt_Start.Text), DateTime.Parse(txt_End.Text).AddDays(1), _areaId) : RequireDA.GetRequireOneStatusList(特定需求單, _areaId); #region ●需求單狀態 int x = 1; var temp2 = (from i in temp orderby i.申請時間 descending select new { 序號 = x++, 需求單ID = i.需求單ID, 種類 = i.種類, 產品編號 = i.產品編號, 預撥數量 = i.預撥數量, 實際數量 = i.實際數量, 申請人 = i.申請人, 申請時間 = i.申請時間.ToString("yyyy-MM-dd HH:mm"), 採購ID = i.採購ID, 傳票ID = (i.傳票ID != 0) ? i.傳票ID.ToString() : "未建立", 審核人 = i.審核人 ?? "無", 狀態 = (i.狀態 == -1) ? "取消" : (i.預撥數量 == 0) ? "移除" : (i.狀態 == 0) ? "待審" : (i.狀態 >= 1 && i.狀態 < 10) ? "待建傳票" : "可印單", }).ToList(); gv_List.DataSource = temp2; gv_List.DataBind(); #endregion ●需求單狀態 var 已審需求單數 = temp2.Select(y => y.需求單ID).Distinct().Count(); var 採購單數 = temp2.Select(y => y.採購ID).Distinct().Count(); var 已審預撥數 = temp2.Where(y => y.審核人 != "無").Sum(y => y.預撥數量); var 未審預撥數 = temp2.Where(y => y.審核人 == "無").Sum(y => y.預撥數量); var 實際數 = temp2.Sum(y => y.實際數量); var 傳票數 = temp2.Where(y => y.傳票ID != "未建立").Select(y => y.傳票ID).Distinct().Count(); var 總筆數 = temp2.Count(); lbl_Count.Text = "總筆數: " + 總筆數 + ", " + "已審需求單數: " + 已審需求單數 + ", " + "採購單數: " + 採購單數 + ", " + "傳票數: " + 傳票數 + ", " + "已審預撥數: " + 已審預撥數 + ", " + "未審預撥數: " + 未審預撥數 + ", " + "實際數: " + 實際數; } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
/// <summary> /// 新增需求單 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_ADD_Click(object sender, EventArgs e) { try { //抓取目前儲位清單 List <product> producttemp = new List <product>(); foreach (GridViewRow row in gv_FList.Rows) { var one = new product(); one.productid = GetCellByName(row, "產品編號").Text; TextBox 調出數 = GetCellByName(row, "調出數").FindControl("txt_num") as TextBox; one.quantity = (調出數 != null) ? int.Parse(調出數.Text) : 0; //數量防呆 if (one.quantity <= 0) { lblMsg.Text = one.productid + " 調出數量不正確!"; return; } producttemp.Add(one); } //統計總數 var temp = (from i in producttemp group i by new { i.productid } into g select new product { productid = g.Key.productid, quantity = g.Sum(x => x.quantity), }).ToList(); //轉成List<string> List <string> ProductList = new List <string>(); foreach (var item in temp) { ProductList.Add(item.productid + "," + item.quantity); } //分為 一般調出 /瑕疵 /問題件 var requireType = 0; if (DDL_SearchType.SelectedItem.Text == "瑕疵") { requireType = 1; } else if (DDL_SearchType.SelectedItem.Text == "問題件") { requireType = 2; } //新增需求單 var result = RequireDA.SetRequireProduct(ProductList, requireType, account, _areaId); lblMsg.Text = result.Reason; if (result.Result == "1") { btn_ADD.Enabled = false; } } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }