示例#1
0
        /// <summary>
        /// CGR05報表
        /// </summary>
        /// <param name="ParameterList">變數清單</param>
        /// <returns>回傳查詢結果</returns>
        public DataTable VGR01_0(ArrayList ParameterList,
                                 string ReportOutputFormat,
                                 ref ReportList.ExcelOtherType EOT
                                 )
        {
            VGRModel.MaintainReturnData bco = new VGRModel.MaintainReturnData(ConntionDB);
            DataTable Dt = bco.GetPrintRpt01Detl(ParameterList);

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("查無資料");
            }
            else
            {
                //取得筆數資料,筆數未滿10的倍數,塞假資料補成10的倍數(因為套表是10筆1張)

                int j = Dt.Rows.Count % 10;

                if (j != 0)
                {
                    for (int i = 0; i < 10 - j; i++)
                    {
                        DataRow drNew = Dt.NewRow();
                        drNew["Item"] = "XXXXXXXXXX"; //只要ITEM是XXXXXXXXXX就抑制顯示
                        drNew["Item_Name"] = "";
                        drNew["Period"] = "";
                        drNew["Return_Qty"] = 0;
                        drNew["Price"] = 0;
                        drNew["Cost"] = 0;
                        Dt.Rows.Add(drNew);
                    }
                }

                return Dt;
            }
        }
示例#2
0
    //新增明細
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";

        string SessionIDName = "VGR01_DTL_" + PageTimeStamp.Value;
        //宣告殘餘數量
        int Remain_Qty = 0;
        
        //調整數量
        int Adjust_Qty = 0;

        #region 檢查輸入值

        string strErr = "";

        string SugLocate = "";

        string strTaxType = "";

        if (SLP_Item.Text == string.Empty)
        {
            strErr = "請輸入品號 ";
            //this.ErrorMsgLabel.Text = strErr;
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR012", "alert('" + strErr + "');", true);
            return;
        }

        if (SLP_Period.Text == string.Empty)
        {
            strErr = "請輸入期間 ";
            //this.ErrorMsgLabel.Text = strErr;
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR012", "alert('" + strErr + "');", true);
            return;
        }

        if (SLP_ReturnQty.Text == string.Empty)
        {
            strErr = "請輸入退貨數量 ";
            //this.ErrorMsgLabel.Text = strErr;
            //ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + this.SLP_ReturnQty.FindControl("TextBoxCode").ClientID + "').focus();", true);   
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR012", "alert('" + strErr + "');", true);
            return;
        }
        //else
        //{
        //    if (int.Parse(SLP_ReturnQty.Text) < 1)
        //    {
        //        strErr = "[退貨數量]欄必須為正整數 ";
        //        this.ErrorMsgLabel.Text = strErr;
        //        SLP_ReturnQty.Text = "";
        //        return;
        //    }
        //}

        if (txtOnHDQty.Text == "")
        {
            txtOnHDQty.Text = "0";
        }

        #endregion

        #region 判斷新增的資料

        DataTable Dt = null;
        DataSet Ds = new DataSet();

        if (MasterOLDData.InnerHtml != "")
        {
            System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
            Ds.ReadXml(sr);
        }

        try
        {
            IVMModel.MaintainRemoveDataDetail dboIVM = new IVMModel.MaintainRemoveDataDetail(ConntionDB);
            VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

            //變更DATATABLE 資料內容
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                Label lblItem = (Label)GridView1.Rows[i].FindControl("lblItem");
                Label lblPeriod = (Label)GridView1.Rows[i].FindControl("lblPeriod");
                Label lblOnhdQty = (Label)GridView1.Rows[i].FindControl("lblOnhdQty");
                Label lblRemainQty = (Label)GridView1.Rows[i].FindControl("lblRemainQty");
                TextBox txtReturnQty = (TextBox)GridView1.Rows[i].FindControl("txtReturnQty");
                

                for (int x = 0; x < Ds.Tables[0].Rows.Count; x++)
                {
                    string Item = Ds.Tables[0].Rows[x]["item"].ToString();
                    string Period = Ds.Tables[0].Rows[x]["period"].ToString();

                    if (lblItem.Text == Item && lblPeriod.Text == Period)
                    {
                        if (int.Parse(txtReturnQty.Text) + int.Parse(lblOnhdQty.Text) >= 0)
                        {
                            Ds.Tables[0].Rows[x]["return_qty"] = txtReturnQty.Text;
                            Ds.Tables[0].Rows[x]["remain_qty"] = (int.Parse(lblOnhdQty.Text) - int.Parse(txtReturnQty.Text)).ToString();

                            if(int.Parse(lblOnhdQty.Text) - int.Parse(txtReturnQty.Text) > 0)
                            {
                                Ds.Tables[0].Rows[x]["adjust_qty"] = "0";
                            }
                            else
                            {
                                Ds.Tables[0].Rows[x]["adjust_qty"] = ((int.Parse(lblOnhdQty.Text) - int.Parse(txtReturnQty.Text)) * -1).ToString();
                            }

                            break;

                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtReturnQty.ClientID + "').focus();", true);
                            return;
                        }
                    }
                }
            }

            if (Ds.Tables.Count == 0)
            {
                //從DB讀取一空table回來
   
                ParameterList.Clear();
                Dt = BCOVGR.QueryReturnDetlEmpty();
            }
            else
            {
                Dt = Ds.Tables[0];
            }

            //如果不是使用BARCODE輸入,取得商品資料
            if(txtBarCode.Text == "")
            {
                string Vendor = "";
                int Onhd_Qty = 0;
                int Price = 0;
                Double Cost = 0;
                string TaxType = "";
                VGRModel.MaintainReturnData BCO = new VGRModel.MaintainReturnData(ConntionDB);
                bool HaveData = BCO.GetItemData(SLP_Item.Text, SLP_Period.Text, hid_LocateSection.Value.ToString(), out Vendor, out Onhd_Qty, out Price, out Cost, out TaxType);
                hid_Vendor_Temp.Value = Vendor.ToString();
                hid_Price.Value = Price.ToString();
                hid_Cost.Value = Cost.ToString();
                hid_Tax_Type.Value = TaxType.ToString() ;
                if (HaveData == true)
                    txtOnHDQty.Text = Onhd_Qty.ToString();
                else
                    txtOnHDQty.Text = "0";
            }

            //檢查是否有重複的品項、期別、儲位
            bool haveData = false;

            ArrayList TaxList = new ArrayList();

            TaxList = TaxTypeList;

            for (int i = 0; i <= Dt.Rows.Count - 1; i++)
            {
                if ((Dt.Rows[i]["item"].ToString() == SLP_Item.Text) &&
                    (Dt.Rows[i]["period"].ToString() == SLP_Period.Text))
                {
                    Remain_Qty = int.Parse(this.txtOnHDQty.Text) - int.Parse(SLP_ReturnQty.Text);
                    if (Remain_Qty < 0)
                    {
                        Adjust_Qty = Remain_Qty * -1;
                    }
                    else
                    {
                        Adjust_Qty = 0;
                    }
                    haveData = true;
                    Dt.Rows[i]["return_qty"] =int.Parse(SLP_ReturnQty.Text);
                    Dt.Rows[i]["old_return_qty"] = int.Parse(SLP_ReturnQty.Text);
                    Dt.Rows[i]["adjust_qty"] = Adjust_Qty;
                    Dt.Rows[i]["remain_qty"] = Remain_Qty;
                    Dt.Rows[i]["isChange"] = "N";
                }
            }

            strTaxType = hid_Tax_Type.Value;

            bool InList = false;

            //紀錄TaxType類型   
            for (int j = 0; j < TaxList.Count; j++)
            {
                if (strTaxType == TaxList[j].ToString())
                {
                    InList = true;
                }
            }

            if (InList == false)
            {
                TaxList.Add(strTaxType);
            }

            TaxTypeList = TaxList;

            if(haveData == false)
            {
                if ((SLP_Vendor.Text != string.Empty && this.hid_CurrentVendor.Value == "")||(SLP_Vendor.Text == string.Empty && this.hid_CurrentVendor.Value == "") || (this.hid_CurrentVendor.Value == this.hid_Vendor_Temp.Value && this.hid_CurrentVendor.Value == this.SLP_Vendor.Text))
                {
                    
                    tempID = 0;

                    DataView tempDT = new DataView();
                    tempDT.Table = Dt.Copy();
                    tempDT.Sort = "ID ASC";
                    if (Dt.Rows.Count != 0)
                    {
                        tempID = Convert.ToInt32(tempDT[Dt.Rows.Count - 1]["ID"].ToString());
                    }

                    DataRow dRow = Dt.NewRow();

                    //ID和CODE暫自訂, 真正寫入CO時會重取
                    int v_ID = tempID + 1;
                    int v_CODE = tempID + 1;

                    Remain_Qty = int.Parse(this.txtOnHDQty.Text) - int.Parse(SLP_ReturnQty.Text);
                    if (Remain_Qty < 0)
                    {
                        Adjust_Qty = Remain_Qty * -1;
                    }
                    else
                    {
                        Adjust_Qty = 0;
                    }

                    dRow["item"] = SLP_Item.Text;
                    dRow["period"] = SLP_Period.Text;
                    if (SLP_Item.Name != "")
                    {
                        dRow["item_name"] = SLP_Item.Name;
                    }
                    else
                    {
                        string ItemName = dboIVM.GetItemName(SLP_Item.Text);
                        dRow["item_name"] = ItemName;
                    }
                    dRow["price"] = hid_Price.Value;
                    dRow["onhd_qty"] = txtOnHDQty.Text;
                    dRow["return_qty"] = SLP_ReturnQty.Text;
                    dRow["old_return_qty"] = SLP_ReturnQty.Text;
                    dRow["remain_qty"] = Remain_Qty;
                    dRow["adjust_qty"] = Adjust_Qty;
                    dRow["cost"] = hid_Cost.Value;
                    dRow["tax_type"] = hid_Tax_Type.Value;
                    dRow["ID"] = v_ID;
                    dRow["isChange"] = "N";
                    Dt.Rows.Add(dRow);

                    if (this.SLP_Vendor.Text == string.Empty)
                    {
                        SLP_Vendor.Text = hid_Vendor_Temp.Value;
                    }

                    if (this.hid_CurrentVendor.Value == "")
                    {
                        this.hid_CurrentVendor.Value = SLP_Vendor.Text;
                    }
                    
                }
                else
                {
                    strErr = "不為此供應商品項 ";
                    txtBarCode.Text = "";
                    this.hid_Vendor_Temp.Value = "";
                    //this.ErrorMsgLabel.Text = strErr;
                    //ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + this.txtBarCode.ClientID + "').focus();", true);
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR012", "alert('" + strErr + "');", true);
                    return;
                }
            }

            #region 使用XML放置到前端資料

            MasterOLDData.InnerHtml = Dt.DataSet.GetXml();

            #endregion
            Session[SessionIDName] = Dt;
            GridView1.DataSource = Dt;
            GridView1.DataBind();

            CalcuTotalRemove(Dt);

            //改由db計算
            //CalcuTotalTax(Dt);

            this.SLP_Item.Text = string.Empty;
            this.SLP_Period.Text = string.Empty;
            this.txtOnHDQty.Text = string.Empty;
            this.SLP_ReturnQty.Text = string.Empty;

            //this.hid_Tax_Total_Amt.Value = string.Empty;
            //this.hid_UnTax_Total_Amt.Value = string.Empty;
            //this.hid_Tax_ReMain_Amt.Value = string.Empty;
            //this.hid_UnTax_ReMain_Amt.Value = string.Empty;
            //this.hid_Tax_Amt.Value = string.Empty;

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                TextBox txtReturnQty = (TextBox)GridView1.Rows[i].FindControl("txtReturnQty");
                Label lblReturnQty = (Label)GridView1.Rows[i].FindControl("lblReturnQty");
                txtReturnQty.Visible = true;
                lblReturnQty.Visible = false;
            }

            if (this.hid_Page_Status.Value == "INSERT")
            {
                GridView1.Columns[8].Visible = false;
                GridView1.Columns[9].Visible = false;
            }
            else if (this.hid_Page_Status.Value == "UPDATE")
            {
                GridView1.Columns[8].Visible = false;
                GridView1.Columns[9].Visible = false;
                GridView1.Columns[11].Visible = false;
            }

            txtBarCode.Text = "";

            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + this.txtBarCode.ClientID + "').focus();", true);

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }
示例#3
0
    private void bindMain()
    {
        try
        {
            if (this.hid_Page_Status.Value == "VIEW")//Model:檢視
            {
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                //將報表列印所需要的報表欄位參數加入HiddenField
                DataTable dtHidField = BCOVGR.GetPrintRpt01Main(Request.QueryString["ID"].ToString());

                if (dtHidField.Rows.Count > 0)
                {
                    this.hidContract.Value=dtHidField.Rows[0]["Business_Contact"].ToString();
                    this.hidFax.Value = dtHidField.Rows[0]["Business_Fax"].ToString();
                    this.hidReturnDate.Value = dtHidField.Rows[0]["Return_Date"].ToString();
                    this.hid_Tax_Total_Amt.Value = dtHidField.Rows[0]["Tax_Total_Amt"].ToString();
                    this.hid_UnTax_Total_Amt.Value = dtHidField.Rows[0]["UnTax_Total_Amt"].ToString();
                    this.hid_Tax_Amt.Value = dtHidField.Rows[0]["Tax_Amt"].ToString();
                }

                DataTable dtResult = BCOVGR.QueryMainByID(Request.QueryString["ID"].ToString());

                if (dtResult.Rows.Count == 1)
                {
                    this.txtRemoveNo.Text = dtResult.Rows[0]["return_no"].ToString();
                    this.txtAdjNo.Text = dtResult.Rows[0]["adjust_no"].ToString();
                    this.txtSum.Text = dtResult.Rows[0]["sum_qty"].ToString();
                    this.SLP_Date.Text = dtResult.Rows[0]["return_date"].ToString();
                    this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString();
                    this.lblCretaeDate.Text = dtResult.Rows[0]["createdate"].ToString();
                    this.SLP_CUser.Text = dtResult.Rows[0]["createuid"].ToString();
                    this.lblMaintainDate.Text = dtResult.Rows[0]["UpdateDate"].ToString();
                    this.SLP_MUser.Text = dtResult.Rows[0]["updateuid"].ToString();
                    this.hid_UpdateTime.Value = dtResult.Rows[0]["UpdateTime"].ToString();
                    VGRModel.GetSysData BCOSysData = new VGRModel.GetSysData(ConntionDB);

                    string Apl_Date = BCOSysData.GetBUSDate();

                    if (Apl_Date == string.Empty)
                    {
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('未取得檢核日期 ');", true);
                        return;
                    }

                    string VAMClosed = BCOSysData.CheckVAMClosedYN(Apl_Date);

                    this.btnEdit.Enabled = VAMClosed == "N";
                    this.btnSave.Enabled = false;
                    this.btnCancel.Enabled = false;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('無資料可供查詢 ');", true);
                    return;
                }
            }
            else if (this.hid_Page_Status.Value == "UPDATE")//Model:編輯(更新)
            {
                //取得TARGET LOCATE SECTION

                ParameterList.Clear();
                ParameterList.Add("B");
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                string strReturnLocateNo = "";

                string strReturnLocateSection = "";

                BCOVGR.QueryTargetLocate(ParameterList, out strReturnLocateNo, out strReturnLocateSection);

                ReturnLocateNo = strReturnLocateNo;

                ReturnLocateSection = strReturnLocateSection;

                hid_LocateSection.Value = ReturnLocateSection;

                if (ReturnLocateSection == string.Empty)
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('廠退作業尚未設定對應儲格'); window.location.href = 'VGR011.aspx';", true);
                }

                DataTable dtResult = BCOVGR.QueryMainByID(Request.QueryString["ID"].ToString());

                if (dtResult.Rows.Count == 1)
                {
                    this.txtRemoveNo.Text = dtResult.Rows[0]["return_no"].ToString();
                    this.txtAdjNo.Text = dtResult.Rows[0]["adjust_no"].ToString();
                    this.txtSum.Text = dtResult.Rows[0]["sum_qty"].ToString();
                    this.SLP_Date.Text = dtResult.Rows[0]["return_date"].ToString();
                    this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString();
                    this.lblCretaeDate.Text = dtResult.Rows[0]["createdate"].ToString();
                    this.SLP_CUser.Text = dtResult.Rows[0]["createuid"].ToString();
                    this.lblMaintainDate.Text = dtResult.Rows[0]["UpdateDate"].ToString();
                    this.SLP_MUser.Text = dtResult.Rows[0]["updateuid"].ToString();
                    this.hid_UpdateTime.Value = dtResult.Rows[0]["UpdateTime"].ToString();
                    this.btnEdit.Visible = false;
                    this.btnAddDetail.Enabled = false;
                }
            }
            else if (this.hid_Page_Status.Value == "INSERT")//Model:新增
            {
                //取得TARGET LOCATE SECTION

                ParameterList.Clear();
                ParameterList.Add("B");
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                string strReturnLocateNo = "";

                string strReturnLocateSection = "";

                BCOVGR.QueryTargetLocate(ParameterList, out strReturnLocateNo, out strReturnLocateSection);

                ReturnLocateNo = strReturnLocateNo;

                ReturnLocateSection = strReturnLocateSection;

                hid_LocateSection.Value = ReturnLocateSection;

                if (ReturnLocateSection == string.Empty)
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('廠退作業尚未設定對應儲格'); window.location.href = 'VGR011.aspx';", true);
                }

                this.SLP_Date.Text = strToday;

                this.SLP_CDate.Text = strToday;
                this.SLP_CUser.Text = Session["UID"].ToString();
                this.SLP_MDate.Text = strToday;
                this.SLP_MUser.Text = Session["UID"].ToString();
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
示例#4
0
    private void bindDetl()
    {
        try
        {
            string SessionIDName = "VGR01_DTL_" + PageTimeStamp.Value;

            if (this.hid_Page_Status.Value == "VIEW")//Model:檢視
            {
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                DataTable dtResult = BCOVGR.QueryDetlByID(Request.QueryString["ID"].ToString());

                #region 使用XML放置到前端資料

                MasterOLDData.InnerHtml = dtResult.DataSet.GetXml();

                #endregion

                if (dtResult.Rows.Count > 0)
                {
                    Session[SessionIDName] = dtResult;

                    GridView1.DataSource = dtResult;
                    GridView1.DataBind();
                    CalcuTotalRemove(dtResult);
                }

            }

            if (this.hid_Page_Status.Value == "UPDATE")//Model:編輯
            {
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                DataTable dtResult = BCOVGR.QueryDetlByID(Request.QueryString["ID"].ToString());

                #region 使用XML放置到前端資料

                MasterOLDData.InnerHtml = dtResult.DataSet.GetXml();

                #endregion

                if (dtResult.Rows.Count > 0)
                {
                    Session[SessionIDName] = dtResult;

                    GridView1.DataSource = dtResult;
                    GridView1.DataBind();

                    CalcuTotalRemove(dtResult);
                    
                }

                ArrayList TaxList = new ArrayList();

                TaxList = TaxTypeList;

                for(int i = 0;i<dtResult.Rows.Count;i++)
                {
                    bool haveTaxRate = false;
                    for (int j = 0; j < TaxList.Count; j++)
                    {
                        if (dtResult.Rows[i]["Tax_type"].ToString()==TaxList[j].ToString())
                        {
                            haveTaxRate = true;
                        }
                    }
                    if (haveTaxRate == false)
                        TaxList.Add(dtResult.Rows[i]["Tax_type"].ToString());
                }

                TaxTypeList = TaxList;
            }
            
            GridView1.Columns[8].Visible = false;
            GridView1.Columns[9].Visible = false;

            if(this.hid_Page_Status.Value != "INSERT")
                GridView1.Columns[11].Visible = false;
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
示例#5
0
    public static string GetItemInfo(string Item,string Period, string LocateSection)
    {
        bool HaveData = false;
        string vendor = string.Empty;
        int OnHd_Qty = 0;
        int Price = 0;
        double Cost = 0;
        string TaxType = string.Empty;

        VGRModel.MaintainReturnData BCO = new VGRModel.MaintainReturnData(ConntionDB);
        HaveData = BCO.GetItemData(Item, Period, LocateSection, out vendor, out OnHd_Qty, out Price, out Cost, out TaxType);

        if (HaveData == true)
            return vendor + "," + OnHd_Qty.ToString() + "," + Price + "," + Cost.ToString() + "," + TaxType;
        else
            return vendor + "," + "0" + "," + Price + "," + Cost.ToString() + "," + TaxType;
    }
示例#6
0
 public static string GetReturnCount(string Vendor, string Today)
 {
     string ReturnCount = "";
     VGRModel.MaintainReturnData BCO = new VGRModel.MaintainReturnData(ConntionDB);
     ReturnCount = BCO.GetVendorReturnCount(Vendor, Today);
     return ReturnCount;
 }
示例#7
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, string reportFormatType)
    {

        try
        {
            VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            report.Load(s_rptFilePath);

            //report.Load(Server.MapPath("./REPORT/VGR01/VGR01R01.rptt"));
            ArrayList DBParameterList = new ArrayList();

            DBParameterList.Add(hiddenID.Value);

            DataTable dtResult = BCOVGR.GetPrintRpt01Detl(DBParameterList);


            int j = dtResult.Rows.Count % 10;

            if (j != 0)
            {
                for (int i = 0; i < 10 - j ; i++)
                {
                    DataRow drNew = dtResult.NewRow();
                    drNew["Item"] = "XXXXXXXXXX";
                    drNew["Item_Name"] = "";
                    drNew["Period"] = "";
                    drNew["Return_Qty"]=0;
                    drNew["Price"]=0;
                    drNew["Cost"] = 0;
                    dtResult.Rows.Add(drNew);
                }
            }

            report.SetDataSource(dtResult);

            DataTable dtMainData = BCOVGR.GetPrintRpt01Main(Request.QueryString["ID"].ToString());

            if (dtMainData.Rows.Count > 0)
            {
                report.SetParameterValue("paraBusiness_Contact1", dtMainData.Rows[0]["Business_Contact"].ToString());
                report.SetParameterValue("paraBusiness_Fax", dtMainData.Rows[0]["Business_Fax"].ToString());
                report.SetParameterValue("paraReturn_Date", dtMainData.Rows[0]["Return_Date"].ToString());
                report.SetParameterValue("paraVendor_Name", dtMainData.Rows[0]["Vendor_Name"].ToString());
                report.SetParameterValue("paraVendor", dtMainData.Rows[0]["Vendor"].ToString());
                report.SetParameterValue("paraReturn_No", dtMainData.Rows[0]["Return_No"].ToString());
                report.SetParameterValue("paraTax_Total_Amt", dtMainData.Rows[0]["Tax_Total_Amt"].ToString());
                report.SetParameterValue("paraUnTax_Total_Amt", dtMainData.Rows[0]["UnTax_Total_Amt"].ToString());
                report.SetParameterValue("paraTax_Amt", dtMainData.Rows[0]["Tax_Amt"].ToString());

                //ParameterFields par1 = new ParameterFields();
                //AddParameter("paraBusiness_Contact1", dtMainData.Rows[0]["Business_Contact1"].ToString(), par1);
                //ParameterFields par2 = new ParameterFields();
                //AddParameter("paraBusiness_Fax", dtMainData.Rows[0]["Business_Fax"].ToString(), par2);
                //ParameterFields par3 = new ParameterFields();
                //AddParameter("paraReturn_Date", dtMainData.Rows[0]["Return_Date"].ToString(), par3);
                //ParameterFields par4 = new ParameterFields();
                //AddParameter("paraVendor_Name", dtMainData.Rows[0]["Vendor_Name"].ToString(), par4);
                //ParameterFields par5 = new ParameterFields();
                //AddParameter("paraVendor", dtMainData.Rows[0]["Vendor"].ToString(), par5);
                //ParameterFields par6 = new ParameterFields();
                //AddParameter("paraReturn_No", dtMainData.Rows[0]["Return_No"].ToString(), par6);
                //ParameterFields par7 = new ParameterFields();
                //AddParameter("paraTax_Total_Amt", dtMainData.Rows[0]["Tax_Total_Amt"].ToString(), par7);
                //ParameterFields par8 = new ParameterFields();
                //AddParameter("paraUnTax_Total_Amt", dtMainData.Rows[0]["UnTax_Total_Amt"].ToString(), par8);
                //ParameterFields par9 = new ParameterFields();
                //AddParameter("paraTax_Amt", dtMainData.Rows[0]["Tax_Amt"].ToString(), par9);

            }
            else
            {
                string strErr = "查無資料";
                this.ErrorMsgLabel.Text = strErr;
                return;
            }

            switch (reportFormatType)
            {
                case "EXCEL":

                    System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                    byte[] bytesXLS = new byte[streamXLS.Length];
                    streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                    streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                    Response.ContentType = "application/vnd.ms-excel";


                    Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                    Response.Flush();
                    Response.Close();

                    break;
                case "PDF":


                    System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    byte[] bytesPDF = new byte[streamPDF.Length];
                    streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                    streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                    Response.ContentType = "application/pdf";
                    Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                    Response.Flush();
                    Response.Close();
                    break;
                default:

                    break;
            }

            report.Close();

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        
    }
示例#8
0
    public static string GetBarCodeData(string txtBarCodeText, string LocateSection)
    {
        bool HaveData = false;
        string item = string.Empty;
        string period = string.Empty;
        string vendor = string.Empty;
        int OnHd_Qty = 0;
        int Price = 0;
        double Cost = 0;
        string TaxType = string.Empty;

        VGRModel.MaintainReturnData BCO = new VGRModel.MaintainReturnData(ConntionDB);
        HaveData = BCO.GetBarCodeData(txtBarCodeText, LocateSection, out item, out period, out vendor, out OnHd_Qty, out Price, out Cost, out TaxType);

        if (HaveData == true)
            return item + "," + period + "," + vendor + "," + OnHd_Qty.ToString() + "," + Price + "," + Cost.ToString() + "," + TaxType;
        else
            return "";
    }
示例#9
0
    private void SaveForm()
    {
        ErrorMsgLabel.Text = "";

        //變數宣告
        string UserID = Session["UID"].ToString();

        string strNow = DateTime.Now.ToString("yyyyMMddHHmmss");

        string IsAdj = "";

        string MainID = "";

        string AdjustNo = "";

        string ReturnNo = "";

        string strErr = "";

        #region 檢查輸入完整性

        if (SLP_Vendor.Text == string.Empty)
        {
            strErr = "請輸入供應商 ";
            this.ErrorMsgLabel.Text = strErr;
            return;
        }

        DataSet Ds = new DataSet();

        if (MasterOLDData.InnerHtml != "")
        {
            System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
            Ds.ReadXml(sr);

            if (Ds.Tables.Count == 0)
            {
                ErrorMsgLabel.Text = "尚未輸入廠商退貨明細資料或退貨數量皆為零";
                return;
            }

        }
        else
        {
            ErrorMsgLabel.Text = "尚未輸入廠商退貨明細資料或退貨數量皆為零";
            return;
        }

        #endregion

        #region 廠退單建立
        //重新調整退貨單輸入數量回傳是否需要建立調整單
        try
        {
            //更新GridView上的廠退單資料
            //變更DATATABLE 資料內容
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                Label lblItem = (Label)GridView1.Rows[i].FindControl("lblItem");
                Label lblPeriod = (Label)GridView1.Rows[i].FindControl("lblPeriod");
                Label lblOnhdQty = (Label)GridView1.Rows[i].FindControl("lblOnhdQty");
                TextBox txtReturnQty = (TextBox)GridView1.Rows[i].FindControl("txtReturnQty");

                for (int x = 0; x < Ds.Tables[0].Rows.Count; x++)
                {
                    string Item = Ds.Tables[0].Rows[x]["item"].ToString();
                    string Period = Ds.Tables[0].Rows[x]["period"].ToString();

                    if (lblItem.Text == Item && lblPeriod.Text == Period)
                    {
                        if (int.Parse(txtReturnQty.Text) + int.Parse(lblOnhdQty.Text) >= 0)
                        {
                            Ds.Tables[0].Rows[x]["return_qty"] = txtReturnQty.Text;
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtReturnQty.ClientID + "').focus();", true);
                            return;
                        }
                        break;
                    }
                }
            }

            //剔除退貨數量是0的資料

            for (int i = Ds.Tables[0].Rows.Count; i > 0; i--)
            {
                if (Ds.Tables[0].Rows[i - 1]["return_qty"].ToString() == "0")
                {
                    Ds.Tables[0].Rows.Remove(Ds.Tables[0].Rows[i - 1]);
                }
            }

            if (Ds.Tables.Count == 0 || Ds.Tables[0].Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "尚未輸入廠商退貨明細資料或退貨數量皆為零";
                return;
            }

            Ds.Tables[0].Columns.Remove("old_return_qty");

            VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

            DataTable dtDetail = BCOVGR.CheckAdjustQty(ReturnLocateSection, Ds.Tables[0],out IsAdj);

            //改由db計算
            //CalcuTotalTax(Ds.Tables[0]);

            ParameterList.Clear();
            ParameterList.Add(UserID);
            ParameterList.Add(strNow);
            ParameterList.Add(IsAdj);
            ParameterList.Add(ReturnLocateSection);
            ParameterList.Add(SLP_Vendor.Text);
            ParameterList.Add("S4");
            ParameterList.Add("E5");

            ParameterList.Add(0);
            ParameterList.Add(0);
            ParameterList.Add(0);
            ParameterList.Add(0);
            ParameterList.Add(0);

            dtDetail.Columns.Remove("item_name");
            dtDetail.Columns.Remove("remain_qty");
            dtDetail.Columns.Remove("id");
            

            BCOVGR.CreateReturnData(ParameterList, dtDetail, null, out ReturnNo, out MainID, out AdjustNo);

            ArrayList IDList = new ArrayList();
            IDList.Add(MainID);

            Session["VGR01QueryID"] = IDList;

            Response.Redirect(string.Format("VGR012.aspx?ID={0}&Code=VGR01&PageMode=1", MainID));

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }
示例#10
0
    private void ShowReport()
    {

        try
        {
            VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);
            ReportDocument report = new ReportDocument();

            report.Load(Server.MapPath("./REPORT/VGR01/VGR01R01.rpt"));

            ArrayList DBParameterList = new ArrayList();

            DBParameterList.Add(Request.QueryString["ID"].ToString());

            DataTable dtResult = BCOVGR.GetPrintRpt01Detl(DBParameterList);

            report.SetDataSource(dtResult);

            DataTable dtMainData = BCOVGR.GetPrintRpt01Main(Request.QueryString["ID"].ToString());

            if (dtMainData.Rows.Count > 0)
            {
                ParameterFields par1 = new ParameterFields();
                AddParameter("paraBusiness_Contact1", dtMainData.Rows[0]["Business_Contact"].ToString(),par1);
                ParameterFields par2 = new ParameterFields();
                AddParameter("paraBusiness_Fax", dtMainData.Rows[0]["Business_Fax"].ToString(), par2);
                ParameterFields par3 = new ParameterFields();
                AddParameter("paraReturn_Date", dtMainData.Rows[0]["Return_Date"].ToString(), par3);
                ParameterFields par4 = new ParameterFields();
                AddParameter("paraVendor_Name", dtMainData.Rows[0]["Vendor_Name"].ToString(), par4); 
                ParameterFields par5 = new ParameterFields();
                AddParameter("paraVendor", dtMainData.Rows[0]["Vendor"].ToString(), par5);
                ParameterFields par6 = new ParameterFields();
                AddParameter("paraReturn_No", dtMainData.Rows[0]["Return_No"].ToString(), par6);
                ParameterFields par7 = new ParameterFields();
                AddParameter("paraTax_Total_Amt", dtMainData.Rows[0]["Tax_Total_Amt"].ToString(), par7);
                ParameterFields par8 = new ParameterFields();
                AddParameter("paraUnTax_Total_Amt", dtMainData.Rows[0]["UnTax_Total_Amt"].ToString(), par8);
                ParameterFields par9 = new ParameterFields();
                AddParameter("paraTax_Amt", dtMainData.Rows[0]["Tax_Amt"].ToString(), par9);

                //this.CryView.ReportSource = null;
                //this.CryView.ParameterFieldInfo.Add(par1[0]);
                //this.CryView.ParameterFieldInfo.Add(par2[0]);
                //this.CryView.ParameterFieldInfo.Add(par3[0]);
                //this.CryView.ParameterFieldInfo.Add(par4[0]);
                //this.CryView.ParameterFieldInfo.Add(par5[0]);
                //this.CryView.ParameterFieldInfo.Add(par6[0]);
                //this.CryView.ParameterFieldInfo.Add(par7[0]);
                //this.CryView.ParameterFieldInfo.Add(par8[0]);
                //this.CryView.ParameterFieldInfo.Add(par9[0]);
                //this.CryView.ReportSource = report;
            }
            else
            {
                string strErr = "尚未更新資料,請先更新資料";
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR012", "alert('" + strErr + "');", true);
                return;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        
    }
示例#11
0
    private void UpdateForm()
    {
        string MainID = Request.QueryString["ID"].ToString();

        ErrorMsgLabel.Text = "";

        string UserID = Session["UID"].ToString();

        string strNow = DateTime.Now.ToString("yyyyMMddHHmmss");

        string ReturnNO = this.txtRemoveNo.Text;

        string strErr = "";

        DataSet Ds = new DataSet();
        if (MasterOLDData.InnerHtml != "")
        {
            System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
            Ds.ReadXml(sr);
        }

        try
        {
            VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

            //更新GridView資料
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                Label lblItem = (Label)GridView1.Rows[i].FindControl("lblItem");
                Label lblPeriod = (Label)GridView1.Rows[i].FindControl("lblPeriod");
                Label lblOnhdQty = (Label)GridView1.Rows[i].FindControl("lblOnhdQty");
                Label lblRemainQty = (Label)GridView1.Rows[i].FindControl("lblRemainQty");
                TextBox txtReturnQty = (TextBox)GridView1.Rows[i].FindControl("txtReturnQty");
                HtmlInputHidden hidRQty = (HtmlInputHidden)GridView1.Rows[i].FindControl("hidRQty");
                HtmlInputHidden hidRQty2 = (HtmlInputHidden)GridView1.Rows[i].FindControl("hidRQty2");

                for (int x = 0; x < Ds.Tables[0].Rows.Count; x++)
                {
                    string Item = Ds.Tables[0].Rows[x]["item"].ToString();
                    string Period = Ds.Tables[0].Rows[x]["period"].ToString();

                    if (lblItem.Text == Item && lblPeriod.Text == Period)
                    {
                        if (int.Parse(txtReturnQty.Text) + int.Parse(lblOnhdQty.Text) >= 0)
                        {
                            Ds.Tables[0].Rows[x]["return_qty"] = txtReturnQty.Text;
                            Ds.Tables[0].Rows[x]["remain_qty"] = (int.Parse(lblOnhdQty.Text) - int.Parse(txtReturnQty.Text)).ToString();

                            if (txtReturnQty.Text != hidRQty2.Value)
                            {
                                Ds.Tables[0].Rows[x]["isChange"] = "Y";
                                isChange = "Y";
                            }
                            break;
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtReturnQty.ClientID + "').focus();", true);
                            return;
                        }
                    }
                }
            }

            if (isChange != "Y")
            {
                strErr = "尚未更新資料,請先更新資料";
                this.ErrorMsgLabel.Text = strErr;
                return;
            }

            #region 檢查輸入完整性

            if (SLP_Vendor.Text == string.Empty)
            {
                strErr = "請輸入供應商 ";
                this.ErrorMsgLabel.Text = strErr;
                return;
            }

            Ds.Tables[0].Columns.Remove("old_return_qty");

            //調整數量所造成的稅方面的影響
            //改由DB負責
            //CalcuTotalTax(Ds.Tables[0]);

            ParameterList.Clear();
            ParameterList.Add(UserID);
            ParameterList.Add(strNow);
            ParameterList.Add(ReturnNO);
            ParameterList.Add(0);
            ParameterList.Add(0);
            ParameterList.Add(0);
            ParameterList.Add(0);
            ParameterList.Add(0);
            ParameterList.Add(MainID);
            ParameterList.Add(this.hid_UpdateTime.Value);

            DataTable dtUpdate = Ds.Tables[0].Clone();

            for (int j = 0; j < Ds.Tables[0].Rows.Count; j++)
            {
                DataRow dr = dtUpdate.NewRow();
                if (Ds.Tables[0].Rows[j]["isChange"].ToString() == "Y")
                {
                    for (int k = 0; k < Ds.Tables[0].Rows[j].ItemArray.Length; k++)
                    {
                        dr[k] = Ds.Tables[0].Rows[j][k];
                    }

                    dtUpdate.Rows.Add(dr);
                }
            }

            dtUpdate.Columns.Remove("item_name");
            dtUpdate.Columns.Remove("remain_qty");
            dtUpdate.Columns.Remove("isChange");

            bool UpdateSuccess =  BCOVGR.UpdateReturnData(ParameterList, dtUpdate, null);

            if (UpdateSuccess != true)
            {
                throw new Exception("更新失敗!");
            }

            ArrayList IDList = new ArrayList();
            IDList.Add(MainID);

            Session["VGR01QueryID"] = IDList;

            Response.Redirect(string.Format("VGR012.aspx?ID={0}&Code=VGR01&PageMode=1", MainID));

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }
示例#12
0
    protected void btnReturnPick_Click(object sender, EventArgs e)
    {

        if ((bool)Session["btnClose"] != true)
        {
            Session["btnClose"] = null;

            if (Session["dtVGRItemSelected"] != null)
            {
                Session["dtVGRItemSelected"] = null;
                
            }
            return;
        }

        string SessionIDName = "VGR01_DTL_" + PageTimeStamp.Value;

        ErrorMsgLabel.Text = "";

        string strErr = "";

        string strTaxType = "";

        DataTable dtPicker;

        if (Session["dtVGRItemSelected"] != null)
        {
            dtPicker = (DataTable)Session["dtVGRItemSelected"];
        }
        else
        {
            strErr = "未選擇商品資訊 ";
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR012", "alert('" + strErr + "');", true);
            return;
        }

        #region 判斷新增的資料

        DataTable Dt = null;
        DataSet Ds = new DataSet();

        if (MasterOLDData.InnerHtml != "")
        {
            System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
            Ds.ReadXml(sr);
        }

        try
        {
            if (Ds.Tables.Count == 0)
            {
                //從DB讀取一空table回來
                

                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);
                ParameterList.Clear();
                Dt = BCOVGR.QueryReturnDetlEmpty();
            }
            else
            {
                //變更DATATABLE 資料內容
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    Label lblItem = (Label)GridView1.Rows[i].FindControl("lblItem");
                    Label lblPeriod = (Label)GridView1.Rows[i].FindControl("lblPeriod");
                    Label lblOnhdQty = (Label)GridView1.Rows[i].FindControl("lblOnhdQty");
                    TextBox txtReturnQty = (TextBox)GridView1.Rows[i].FindControl("txtReturnQty");

                    for (int x = 0; x < Ds.Tables[0].Rows.Count; x++)
                    {
                        string Item = Ds.Tables[0].Rows[x]["item"].ToString();
                        string Period = Ds.Tables[0].Rows[x]["period"].ToString();

                        if (lblItem.Text == Item && lblPeriod.Text == Period)
                        {
                            if (int.Parse(txtReturnQty.Text) + int.Parse(lblOnhdQty.Text) >= 0)
                            {
                                Ds.Tables[0].Rows[x]["return_qty"] = txtReturnQty.Text;
                                Ds.Tables[0].Rows[x]["remain_qty"] = (int.Parse(lblOnhdQty.Text) - int.Parse(txtReturnQty.Text)).ToString();

                                if (int.Parse(lblOnhdQty.Text) - int.Parse(txtReturnQty.Text) > 0)
                                {
                                    Ds.Tables[0].Rows[x]["adjust_qty"] = "0";
                                }
                                else
                                {
                                    Ds.Tables[0].Rows[x]["adjust_qty"] = ((int.Parse(lblOnhdQty.Text) - int.Parse(txtReturnQty.Text)) * -1).ToString();
                                }
                                break;
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "document.getElementById('" + txtReturnQty.ClientID + "').focus();", true);
                                return;
                            }
                        }
                    }
                }

                Dt = Ds.Tables[0];
            }

            for (int RowNum = 0; RowNum < dtPicker.Rows.Count; RowNum++)
            {
                //檢查是否有重複的品項、期別、儲位
                bool haveData = false;

                ArrayList TaxList = new ArrayList();

                TaxList = TaxTypeList;

                for (int i = 0; i <= Dt.Rows.Count - 1; i++)
                {
                    if (Dt.Rows[i]["item"].ToString() == dtPicker.Rows[RowNum]["item"].ToString() &&
                        (Dt.Rows[i]["period"].ToString() == dtPicker.Rows[RowNum]["period"].ToString()))
                    {
                        haveData = true;
                        Dt.Rows[i]["item_name"] = dtPicker.Rows[RowNum]["item_name"].ToString();
                        Dt.Rows[i]["price"] = int.Parse(dtPicker.Rows[RowNum]["price"].ToString());
                        Dt.Rows[i]["onhd_qty"] = int.Parse(dtPicker.Rows[RowNum]["onhd_qty"].ToString());
                        Dt.Rows[i]["return_qty"] = int.Parse(dtPicker.Rows[RowNum]["return_qty"].ToString());
                        Dt.Rows[i]["old_return_qty"] = int.Parse(dtPicker.Rows[RowNum]["return_qty"].ToString());
                        Dt.Rows[i]["adjust_qty"] = int.Parse(dtPicker.Rows[RowNum]["adjust_qty"].ToString());
                        Dt.Rows[i]["remain_qty"] = int.Parse(dtPicker.Rows[RowNum]["remain_qty"].ToString());
                        Dt.Rows[i]["cost"] = double.Parse(dtPicker.Rows[RowNum]["cost"].ToString());
                        Dt.Rows[i]["tax_type"] = dtPicker.Rows[RowNum]["tax_type"].ToString();
                        Dt.Rows[i]["isChange"] = "N";
                    }
                }

                if (haveData != true)
                {

                    strTaxType = dtPicker.Rows[RowNum]["tax_type"].ToString();

                    bool InList = false;

                    //紀錄TaxType類型   
                    for (int j = 0; j < TaxList.Count; j++)
                    {
                        if (strTaxType == TaxList[j].ToString())
                        {
                            InList = true;
                        }
                    }

                    if (InList == false)
                    {
                        TaxList.Add(strTaxType);
                    }

                    TaxTypeList = TaxList;

                    tempID = 0;

                    DataView tempDT = new DataView();
                    tempDT.Table = Dt.Copy();
                    tempDT.Sort = "ID ASC";
                    if (Dt.Rows.Count != 0)
                    {
                        tempID = Convert.ToInt32(tempDT[Dt.Rows.Count - 1]["ID"].ToString());
                    }

                    DataRow dRow = Dt.NewRow();

                    //ID和CODE暫自訂, 真正寫入CO時會重取
                    int v_ID = tempID + 1;
                    int v_CODE = tempID + 1;

                    dRow["item"] = dtPicker.Rows[RowNum]["item"].ToString();
                    dRow["period"] = dtPicker.Rows[RowNum]["period"].ToString();
                    dRow["item_name"] = dtPicker.Rows[RowNum]["item_name"].ToString();
                    dRow["price"] = int.Parse(dtPicker.Rows[RowNum]["price"].ToString());
                    dRow["onhd_qty"] = int.Parse(dtPicker.Rows[RowNum]["onhd_qty"].ToString());
                    dRow["return_qty"] = int.Parse(dtPicker.Rows[RowNum]["return_qty"].ToString());
                    dRow["old_return_qty"] = int.Parse(dtPicker.Rows[RowNum]["return_qty"].ToString());
                    dRow["remain_qty"] = int.Parse(dtPicker.Rows[RowNum]["remain_qty"].ToString());
                    dRow["adjust_qty"] = int.Parse(dtPicker.Rows[RowNum]["adjust_qty"].ToString());
                    dRow["cost"] = double.Parse(dtPicker.Rows[RowNum]["cost"].ToString());
                    dRow["tax_type"] = dtPicker.Rows[RowNum]["tax_type"].ToString();
                    dRow["isChange"] = "N";
                    dRow["ID"] = v_ID;
                    Dt.Rows.Add(dRow);
                }

            }

            #region 使用XML放置到前端資料

            MasterOLDData.InnerHtml = Dt.DataSet.GetXml();

            hid_CurrentVendor.Value = SLP_Vendor.Text;

            #endregion

            Session[SessionIDName] = Dt;

            GridView1.DataSource = Dt;
            GridView1.DataBind();

            GridView1.Columns[8].Visible = false;
            GridView1.Columns[9].Visible = false;

            CalcuTotalRemove(Dt);

            //改由db計算
            //CalcuTotalTax(Dt);

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                TextBox txtReturnQty = (TextBox)GridView1.Rows[i].FindControl("txtReturnQty");
                Label lblReturnQty = (Label)GridView1.Rows[i].FindControl("lblReturnQty");
                txtReturnQty.Visible = true;
                lblReturnQty.Visible = false;
            }

            Session["dtVGRItemSelected"] = null;
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }
    private void SelectAll()
    {
        //新程式
        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
        ErrorMsgLabel.Text = "";
        try
        {
            VGRModel.MaintainReturnData BCOIVM = new VGRModel.MaintainReturnData(ConnectionDB);
            dtClassAndItemSelected = BCOIVM.GetStockByVendor(Vendor, SLP_RootNo.Text, LocateSection);
            Session[SessionIDName] = dtClassAndItemSelected;
            GridView1.DataSource = dtClassAndItemSelected;
            GridView1.PageSize = 20;
            //GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            GridView1.PageIndex = 0;
            GridView1.DataBind();
            GridView1.SelectedIndex = -1;

            if (dtClassAndItemSelected == null || (dtClassAndItemSelected != null && dtClassAndItemSelected.Rows.Count <= 0))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true);
                return;
            }

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                CheckBox chk_Sgl = (CheckBox)GridView1.Rows[i].FindControl("chk_Sgl");
                chk_Sgl.Checked = true;
            }

            CheckBox chbAll = (CheckBox)GridView1.HeaderRow.FindControl("chbAll");
            chbAll.Checked = true;
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.ToString();
        }
    }
示例#14
0
    private void dataBind()
    {
        ErrorMsgLabel.Text = "";

        string SessionIDName = "VGR011_" + PageTimeStamp.Value;

        VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

        ArrayList ParameterList = new ArrayList();
        ParameterList.Add(txtReturnNo.Text);
        ParameterList.Add(SLP_Date.Text);
        ParameterList.Add(SLP_Vendor.Text);
        ParameterList.Add(SLP_Item.Text);
        ParameterList.Add(SLP_Period.Text);
        ParameterList.Add(int.Parse(TextBoxRowCountLimit.Text));

        DataTable Dt = BCOVGR.QueryMainByFind(ParameterList);

        if (Dt.Rows.Count == 0)
        {
            this.ErrorMsgLabel.Text = "查無資料";
        }

        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;

        ArrayList IDList = new ArrayList();

        for (int i = 0; i < Dt.Rows.Count; i++)
        {
            IDList.Add(Dt.Rows[i]["ID"].ToString());
        }

        Session["VGR01QueryID"] = IDList;

        //設定分頁大小
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        //

        GridView1.PageIndex = 0;
        GridView1.DataBind();

    }
示例#15
0
        public bool GetBarCodeData(string FullBarCode, string LocateSection, out string Item, out string Period, out int OnHd_Qty, out Double Cost)
        {
            try
            {
                bool HaveDate = false;

                Item = string.Empty;
                Period = string.Empty;
                string Vendor = "";
                OnHd_Qty = 0;
                int Price = 0;
                Cost = 0;
                string TaxType = "";

                DBOVGR.MaintainReturnData CheckBarCode = new DBOVGR.MaintainReturnData(strConn);
                HaveDate = CheckBarCode.GetBarCodeData(FullBarCode, LocateSection, out Item, out Period, out Vendor, out OnHd_Qty, out Price, out Cost, out TaxType);
                if (Item != string.Empty && Period != string.Empty)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }