Пример #1
0
        //导入缺料明细
        protected void import_short_detail(object sender, EventArgs e)
        {
            //导入缺料明细前,先把框框里的数据清空
            GridView1.DataSource = null;
            GridView1.DataBind();

            DataSet ds;

            if (string.IsNullOrWhiteSpace(invoice_no.Value))
            {
                PageUtil.showToast(this, "请填写单据号");
                return;
            }
            string Invoice_no = invoice_no.Value;

            if (invoiceDC.getIssueHeaderBySome(Invoice_no, "", "") == null)
            {
                PageUtil.showToast(this, "请确定单据号存在");
                return;
            }
            ds = invoiceDC.getIssueHeaderBySome(Invoice_no, "", "");

            //工单领料时才需要导入缺料明细
            if (ds.Tables[0].Rows[0]["issue_type"].ToString() == "工单领料")
            {
                string Issue_wo_no = DropDownList_issue_wo_no.SelectedValue.ToString();


                if (DropDownList_issue_wo_no.SelectedValue.ToString() == "--选择工单--")
                {
                    PageUtil.showToast(this, "请选择工单后再做操作");
                    return;
                }


                //避免重复点击导入缺料明细按钮(每一个领料单只能导入一次缺料明细)
                DataSet ds2;
                ds2 = invoiceDC.getIssueLineBySome(Invoice_no, "");
                if (ds2 != null)
                {
                    PageUtil.showToast(this, "该领料单已导入过缺料明细,请勿重复导入缺料明细!");
                    return;
                }


                //从数据库中获取该单据对应的line_num值
                int Line_num = invoiceDC.getIssueLine_numByInvoice_no(Invoice_no);
                //Line_num生成失败
                if (Line_num == -1)
                {
                    PageUtil.showToast(this, "添加单身失败");
                    return;
                }

                DataTable table = new DataTable();

                table = GetGridViewData(table);

                //当框框中已经有一条数据及以上时,需要对line_num做处理
                if (table.Rows.Count >= 1)
                {
                    Line_num = Line_num + table.Rows.Count;
                }

                //获取缺料明细
                DataSet ds3 = invoiceDC.getShort_detail(Issue_wo_no);

                //遍历查询出来的每行
                foreach (DataRow Dr in ds3.Tables[0].Rows)
                {
                    DataRow sourseRow = table.NewRow();
                    sourseRow["wo_no"]            = Issue_wo_no;
                    sourseRow["line_num"]         = Line_num;
                    sourseRow["item_name"]        = Dr["item_name"];
                    sourseRow["peration_seq_num"] = "请修改制程";
                    sourseRow["issued_qty"]       = Dr["issued_qty"];
                    sourseRow["simulated_qty"]    = Dr["simulated_qty"];
                    sourseRow["required_qty"]     = Dr["required_qty"];
                    //sourseRow["frame_key"] = Frame_key;
                    sourseRow["issued_sub"]  = "请修改库别";
                    sourseRow["create_man"]  = user;
                    sourseRow["create_time"] = DateTime.Now;

                    table.Rows.Add(sourseRow);
                    Line_num++;  //line_num递增
                }

                Session["TaskTable"] = table;

                GridView1.DataSource = table;

                GridView1.DataBind();

                //提交单个单身数据成功时,清除用户已填写的单身数据,方便用户填写下一个单身
                DropDownList_issue_wo_no.SelectedValue       = "--选择工单--";
                DropDownList_item_name.SelectedValue         = "--选择小料号--";
                DropDownList_operation_seq_num.SelectedValue = "--选择制程--";
                DropDownList_issue_sub_key.SelectedValue     = "--选择库别--";
                //DropDownList_frame_key.SelectedValue = "--选择料架--";

                issued_qty.Value    = "";
                simulated_qty.Value = "";
                required_qty.Value  = "";

                PageUtil.showToast(this, "导入缺料明细成功,请修改库别与制程后点击更新按钮!");
                return;
            }
        }