Example #1
0
        ////调出料架发生改变时
        //protected void DropDownList_out_frame_key_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (invoice_no.Value == "")
        //    {
        //        PageUtil.showToast(this, "请输入调拨单号再操作");
        //        return;
        //    }
        //    DataSet ds = invoiceDC.getExchangeHeaderBySome(invoice_no.Value, "");
        //    if (ds == null)
        //    {
        //        PageUtil.showToast(this, "请确保该调拨单号存在,再操作");
        //        return;
        //    }

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

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

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

        //    //调出料架与料号的二级联动
        //    try
        //    {
        //        DropDownList_item_name.Items.Clear();

        //        string text = DropDownList_out_frame_key.SelectedValue.ToString();
        //        DataSet ds_item_name = invoiceDC.getItem_nameByFrame(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
        //    //{
        //    //    string frame_key = DropDownList_out_frame_key.SelectedValue.ToString();
        //    //    string item_name = DropDownList_item_name.SelectedValue.ToString();
        //    //    DataSet ds2 = invoiceDC.getOnhandQty(frame_key, item_name);

        //    //    exchange_limit.Value = ds2.Tables[0].Rows[0]["onhand_qty"].ToString();
        //    //}
        //    //catch (Exception e2)
        //    //{
        //    //    PageUtil.showToast(this, "获取调拨上限失败,请检查是否有关联数据");
        //    //    return;
        //    //}

        //    ////料号与调入料架的二级联动
        //    //try
        //    //{
        //    //    DropDownList_in_frame_key.Items.Clear();

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

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

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

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

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

        ////调出料号改变时
        //protected void DropDownList_item_name_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (invoice_no.Value == "")
        //    {
        //        PageUtil.showToast(this, "请输入调拨单号再操作");
        //        return;
        //    }
        //    DataSet ds = invoiceDC.getExchangeHeaderBySome(invoice_no.Value, "");
        //    if (ds == null)
        //    {
        //        PageUtil.showToast(this, "请确保该调拨单号存在,再操作");
        //        return;
        //    }

        //    ////调出料号改变时,改变调拨上限
        //    //try
        //    //{
        //    //    string frame_key = DropDownList_out_frame_key.SelectedValue.ToString();
        //    //    string item_name = DropDownList_item_name.SelectedValue.ToString();
        //    //    DataSet ds2 = invoiceDC.getOnhandQty(frame_key, item_name);

        //    //    exchange_limit.Value = ds2.Tables[0].Rows[0]["onhand_qty"].ToString();
        //    //}
        //    //catch (Exception e2)
        //    //{
        //    //    PageUtil.showToast(this, "获取调拨上限失败,请检查是否有关联数据");
        //    //    return;
        //    //}

        //    //料号与调入料架的二级联动
        //    try
        //    {
        //        DropDownList_in_frame_key.Items.Clear();

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

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

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

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

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


        ////调入料架发生改变时
        //protected void DropDownList_in_frame_key_SelectedIndexChanged(object sender, EventArgs e)
        //{

        //    if (invoice_no.Value == "")
        //    {
        //        PageUtil.showToast(this, "请输入调拨单号再操作");
        //        return;
        //    }
        //    DataSet ds = invoiceDC.getExchangeHeaderBySome(invoice_no.Value, "");
        //    if (ds == null)
        //    {
        //        PageUtil.showToast(this, "请确保该调拨单号存在,再操作");
        //        return;
        //    }

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

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

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


        //生成一个调拨单单据号
        protected void NewInvoice_no(object sender, EventArgs e)
        {
            string strInvoice_no = invoice_no.Value;

            if (!string.IsNullOrWhiteSpace(strInvoice_no))
            {
                PageUtil.showToast(this, "单据号已生成,请勿重复操作");

                return;
            }

            int     end;
            string  end_text;
            string  month = string.Empty;
            string  year  = string.Empty;
            DataSet ds;

            ds = invoiceDC.getTheNewestExchangeHeaderByCreatetime();

            //判断数据库是否有数据,没有数据则初始化一个流水号
            if (ds == null)
            {
                end_text = "00001";

                month = DateTime.Now.Month.ToString();

                year = DateTime.Now.Year.ToString();


                //为月份补0
                for (int i = month.Length; i < 2; i++)
                {
                    month = "0" + month;
                }

                //截取年份后两位
                year = year.Substring(2, 2);
            }
            else
            {
                end = int.Parse(ds.Tables[0].Rows[0]["exchange_header_id"].ToString());

                //截取上一个单号的后5位,即从第5位开始的5位(0开始增)
                string sInvoice_no = ds.Tables[0].Rows[0]["invoice_no"].ToString();
                string result      = sInvoice_no.Substring(5, 5);
                end = int.Parse(result);

                string last_month = sInvoice_no.Substring(3, 2);
                string last_year  = sInvoice_no.Substring(1, 2);

                ////判断id是否为99998,是则取下一个流水号为99999,否则取余+1作为下一个流水号
                //end = end % 99998 == 0 ? 99998 + 1 : end % 99999 + 1;

                //当end为99999时,重置从1开始计数。否则,递增
                if (end == 99999)
                {
                    end = 1;
                }
                else
                {
                    end = end + 1;
                }

                end_text = end.ToString();


                //为流水号补0
                for (int i = end_text.Length; i < 5; i++)
                {
                    end_text = "0" + end_text;
                }

                month = DateTime.Now.Month.ToString();

                year = DateTime.Now.Year.ToString();

                year = year.Substring(2, 2);

                for (int i = month.Length; i < 2; i++)
                {
                    month = "0" + month;
                }

                //新月份或新的一年,从1重新计数
                if (month != last_month)
                {
                    end_text = "00001";
                }
                if (year != last_year)
                {
                    end_text = "00001";
                }
            }

            invoice_no.Value = "T" + year + month + end_text;
        }