Example #1
0
        //查询单头单身
        protected void search(object sender, EventArgs e)
        {
            try
            {
                string Invoice_no = DropDownList_invoice_no.SelectedValue.ToString();

                string   first_time = "2016-07-01 00:00:00";
                DateTime start_time = Convert.ToDateTime(first_time);
                DateTime end_time   = DateTime.Now;

                if (Invoice_no == "--选择退料单号--")
                {
                    Invoice_no = "";
                }

                ReturnHeaderReater.DataSource = invoiceDC.getReturnHeaderBySome(Invoice_no, "", "");
                ReturnLineReater.DataSource   = invoiceDC.getReturnLineBySome(Invoice_no, "", "", start_time, end_time);

                if (ReturnHeaderReater.DataSource == null)
                {
                    PageUtil.showToast(this, "无相关退料单头信息");
                }
                ReturnHeaderReater.DataBind();

                if (ReturnLineReater.DataSource == null)
                {
                    PageUtil.showToast(this, "无相关退料单身信息");
                }
                ReturnLineReater.DataBind();
            }
            catch (Exception e1)
            {
                PageUtil.showToast(this, "查询失败");
            }
        }
        //显示打印页面中的所有数据
        protected void DataView()
        {
            InvoiceDC invoiceDC = new InvoiceDC();

            try
            {
                //绑定其他数据
                DataSet dataset_header = new DataSet();
                dataset_header    = invoiceDC.getReturnHeaderBySome(select_text.Value, "", "");
                flex_value.Value  = dataset_header.Tables[0].Rows[0]["flex_value"].ToString();
                description.Value = dataset_header.Tables[0].Rows[0]["description"].ToString();
                remark.Value      = dataset_header.Tables[0].Rows[0]["remark"].ToString();
                return_type.Value = dataset_header.Tables[0].Rows[0]["return_type"].ToString();
                status.Value      = dataset_header.Tables[0].Rows[0]["status"].ToString();


                //绑定Repeater中数据
                DataSet dataset_line = new DataSet();
                dataset_line = invoiceDC.getReturnLineBySome(select_text.Value, "", "", Convert.ToDateTime("2016-07-01 00:00:00"), DateTime.Now);

                printMaterialReturningRepeater.DataSource = dataset_line;
                printMaterialReturningRepeater.DataBind();
            }
            catch (Exception e)
            {
                PageUtil.showToast(this, "数据库中没有对应数据,请重新输入领料单号");
            }
        }
        protected void Select(object sender, EventArgs e)
        {
            try
            {
                //string Invoice_no = DropDownList_invoice_no.SelectedValue.ToString();
                //string Item_name = DropDownList_item_name.SelectedValue.ToString();
                string Invoice_no  = invoice_no.Value;
                string Item_name   = item_name.Value;
                string Return_type = Request.Form["return_type"];

                //if (Invoice_no == "--选择退料单号--")
                //    Invoice_no = "";
                //if (Item_name == "--选择料号--")
                //    Item_name = "";

                string FIRST_TIME = inpend.Value;
                if (FIRST_TIME == "")
                {
                    FIRST_TIME = "2016-07-01 00:00:00";
                }

                start_time = Convert.ToDateTime(FIRST_TIME);
                string LAST_TIME = inpstart.Value;
                end_time = Convert.ToDateTime(LAST_TIME);

                GridView_header.DataSource = invoiceDC.getReturnHeaderBySome(Invoice_no, Return_type, "");
                GridView_line.DataSource   = invoiceDC.getReturnLineBySome(Invoice_no, Item_name, Return_type, start_time, end_time);

                if (GridView_header.DataSource == null)
                {
                    PageUtil.showToast(this, "无相关退料单头信息");
                }
                GridView_header.DataBind();

                if (GridView_line.DataSource == null)
                {
                    PageUtil.showToast(this, "无相关退料单身信息");
                }
                GridView_line.DataBind();
            }
            catch (Exception e1)
            {
                PageUtil.showToast(this, "查询失败");
            }
        }
        //选择退料工单号时触发
        protected void DropDownList_return_wo_no_SelectedIndexChanged(object sender, EventArgs e)
        {
            //退料工单号与料号的二级联动,从工单物料需求表中带出料号
            try
            {
                DropDownList_item_name.Items.Clear();

                string  text         = DropDownList_return_wo_no.SelectedValue.ToString();
                DataSet ds_item_name = invoiceDC.getItem_nameByReturn_wo_no(text);
                if (ds_item_name != null)
                {
                    DropDownList_item_name.DataSource     = ds_item_name.Tables[0].DefaultView;
                    DropDownList_item_name.DataValueField = "item_name";
                    DropDownList_item_name.DataTextField  = "item_name";
                    DropDownList_item_name.DataBind();
                }

                DropDownList_item_name.Items.Insert(0, "--选择料号--");
                DropDownList_item_name.SelectedIndex = 1;
            }
            catch (Exception e2)
            {
                PageUtil.showToast(this, "退料工单号与料号二级联动失败,请检查工单物料需求表是否有关联数据");
                return;
            }

            //根据工单号和料号,从工单物料需求表中带出发料量+领料量
            try
            {
                if (invoice_no.Value == "")
                {
                    PageUtil.showToast(this, "请输入退料单号再做操作");
                    return;
                }

                DataSet ds = invoiceDC.getReturnHeaderBySome(invoice_no.Value, "", "");
                if (ds == null)
                {
                    PageUtil.showToast(this, "该退料单不存在,请重新输入(请确保申请成功)");
                    return;
                }

                //检测是否为工单退料,如果是,则退料上限为发料量+领料量从工单物料需求表中带出
                if (ds.Tables[0].Rows[0]["return_type"].ToString() == "工单退料")
                {
                    DataSet ds2 = invoiceDC.getRequirement(DropDownList_return_wo_no.SelectedValue.ToString(), DropDownList_item_name.SelectedValue.ToString());

                    Limit_return = int.Parse(ds2.Tables[0].Rows[0]["issue_invoice_qty"].ToString()) + int.Parse(ds2.Tables[0].Rows[0]["issued_qty"].ToString());

                    return_limit.Value = Limit_return.ToString();
                }
                else
                {
                    return_limit.Value = "none";
                }
            }
            catch (Exception ex)
            {
                PageUtil.showToast(this, "获取领料量,发料量失败,请检查是否工单物料需求表有关联数据");
                return;
            }

            ////料号与料架的二级联动,去库存明细表中找有此料号的料架
            //try
            //{
            //    DropDownList_frame_key.Items.Clear();

            //    string text = DropDownList_item_name.SelectedValue.ToString();
            //    DataSet ds_frame_key = invoiceDC.getFrameByItem_name(text);
            //    if (ds_frame_key != null)
            //    {
            //        DropDownList_frame_key.DataSource = ds_frame_key.Tables[0].DefaultView;
            //        DropDownList_frame_key.DataValueField = "frame_name";
            //        DropDownList_frame_key.DataTextField = "frame_name";
            //        DropDownList_frame_key.DataBind();
            //    }

            //    DropDownList_frame_key.Items.Insert(0, "--选择料架--");
            //    DropDownList_frame_key.SelectedIndex = 1;
            //}
            //catch (Exception e2)
            //{
            //    PageUtil.showToast(this, "料号与料架二级联动失败,请检查库存明细表是否有关联数据");
            //    return;
            //}

            ////料架与库别的二级联动
            //try
            //{
            //    DropDownList_return_sub_key.Items.Clear();

            //    string text = DropDownList_frame_key.SelectedValue.ToString();
            //    DataSet ds_return_sub_key = invoiceDC.getSubinventoryByFrame(text);
            //    if (ds_return_sub_key != null)
            //    {
            //        DropDownList_return_sub_key.DataSource = ds_return_sub_key.Tables[0].DefaultView;
            //        DropDownList_return_sub_key.DataValueField = "subinventory_key";
            //        DropDownList_return_sub_key.DataTextField = "subinventory_name";
            //        DropDownList_return_sub_key.DataBind();
            //    }

            //    DropDownList_return_sub_key.Items.Insert(0, "--选择库别--");
            //    DropDownList_return_sub_key.SelectedIndex = 1;
            //}
            //catch (Exception e2)
            //{
            //    PageUtil.showToast(this, "料架与库别二级联动失败,请检查是否有关联数据");
            //    return;
            //}
        }