Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
0
        /// <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);
            }
        }