コード例 #1
0
ファイル: CAM031.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void BindData()
    {
        MaintainStoreDiff bco = new MaintainStoreDiff(ConntionDB);
        ArrayList parameterList = new ArrayList();
        parameterList.Add(txtGroup.Text);
        parameterList.Add(txtStore.Text);
        parameterList.Add(txtProfit.Text);
        parameterList.Add(txtRoute.Text);
        parameterList.Add(txtStep.Text);
        parameterList.Add(txtAcctUID.Text);
        parameterList.Add(ddlIOType.Text);
        parameterList.Add(ddlCheckSource.Text);
        parameterList.Add(txtPatchDate.StartDate);
        parameterList.Add(txtPatchDate.EndDate);
        parameterList.Add(txtSignDate.StartDate);
        parameterList.Add(txtSignDate.EndDate);
        parameterList.Add(txtStBackNo.Text);
        parameterList.Add(txtChainSourceNo.Text);
        parameterList.Add(txtDiffNo.Text);
        parameterList.Add(txtPatchNo.Text);
        parameterList.Add(txtAdjustNo.Text);
        parameterList.Add(txtItem.Text);
        parameterList.Add(rboUpload.Text);
        parameterList.Add(ddlDesc.Text);
        parameterList.Add(txtMemo.Text);
        parameterList.Add(rblTaxType.Text);
        parameterList.Add(txtRootNo.Text);
        parameterList.Add(rblIsSchedule.Text);
        parameterList.Add(ddlACStatus.Text);
        parameterList.Add(txtAcBalanceDateS.Text);
        parameterList.Add(txtAcBalanceDate.Text);
        parameterList.Add(TextBoxRowCountLimit.Text);
        parameterList.Add(chkLike.Checked);

        parameterList.Add(txtZ_O.Text);
        parameterList.Add(txtSAL_ID.Text);
        parameterList.Add(slpCREATEUID.Text);
        parameterList.Add(slpUPDATEUID.Text);

        parameterList.Add(slpPROMOTE_ID_S.Text);
        parameterList.Add(slpPROMOTE_ID_E.Text);

        DataTable dt = bco.QueryDiffPatchByFind(parameterList);
        string SessionIDName = "CAM031_" + PageTimeStamp.Value;
        Session[SessionIDName] = dt;
        GridView1.DataSource = dt;
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();
        if (dt.Rows.Count > 0)
        {
            StringCollection sc = new StringCollection();
            foreach (DataRow dr in dt.Rows)
            {
                sc.Add(dr["ID"].ToString());
            }
            Session["CAM03CodeCollection"] = sc;
        }
        else
        {
            ErrorMsgLabel.Text = "查無資料";
        }
    }
コード例 #2
0
ファイル: CAM032.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void txtStBackNo_Onblur()
    {
        ErrorMsgLabel.Text = "";

        MaintainStoreDiff bco = new MaintainStoreDiff(ConnectionDB);
        ArrayList parameterList = new ArrayList();
        parameterList.Add(txtStBackNo.Text);
        DataTable dt = bco.GetSTBACKNO(parameterList);
        if (dt.Rows.Count > 0)
        {
            ErrorMsgLabel.Text = "憑證單號不可重覆";
        }
    }
コード例 #3
0
ファイル: CAM032.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void btnModify_Click(object sender, EventArgs e)
    {
        switch (OperationMode)
        {
            case OpMode.View:
                try
                {
                    OperationMode = OpMode.Edit;
                    ddlIOType.Enabled = false;
                    btnCopy.Visible = false;
                    chkUpload.Enabled = true;
                    txtChainSourceNo.ReadOnly = false;
                    txtChainSourceNo.CssClass = "";
                    ddlDesc.ReadOnly = false;
                    txtMemo.ReadOnly = false;
                    txtMemo.CssClass = "";
                    GridView1.Columns[14].Visible = false;
                    GridView1.Columns[15].Visible = false;
                    btnAddDiffItem.Visible = false;

                    if (ddlACStatus.Text == "1")
                    {
                        txtSignDate.ReadOnly = false;
                    }

                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Copy, false, string.Empty, null, WUI_GMToolbarV.ClickAction.ButtonClick);
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, "", btnModify,
                    WUI_GMToolbarV.ClickAction.ButtonClick);
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, "", null,
                    WUI_GMToolbarV.ClickAction.ButtonClick);
                }
                catch (Exception ex)
                {
                    WaringLogProcess(ex.Message);
                    this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
                }
                finally { Finally_Function(); }

                break;

            case OpMode.Edit:

                try
                {
                    if (ddlACStatus.Text == "1")
                    {
                        string strDIFF_QTY = "";

                        if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(txtSignDate.Text)
                           || string.IsNullOrEmpty(txtStBackNo.Text) || string.IsNullOrEmpty(txtBusDate.Text)
                           || string.IsNullOrEmpty(ddlIOType.Text))
                        {
                            ErrorMsgLabel.Text = "店號、簽收日期、補帳日期、憑證單號、單據類型需有值";
                            return;
                        }


                        if (string.Compare(txtSignDate.Text, hdfCREATEDATE.Value, false) > 0)
                        {
                            ErrorMsgLabel.Text = "簽收日期不可大於建立日期";
                            return;
                        }

                        if (string.Compare(txtBusDate.Text, hdfCREATEDATE.Value, false) > 0)
                        {
                            ErrorMsgLabel.Text = "補帳日期不可大於建立日期";
                            return;
                        }

                        DataTable dt = DiffData.GetChanges(DataRowState.Deleted);
                        int inCount = (dt == null ? 0 : dt.Rows.Count);

                        if (DiffData.Rows.Count > 0)
                        {
                            if (inCount == DiffData.Rows.Count)
                            {
                                ErrorMsgLabel.Text = "需有明細資料";
                                return;
                            }
                        }
                        else
                        {
                            ErrorMsgLabel.Text = "需有明細資料";
                            return;
                        }

                        foreach (DataRow dr in DiffData.Rows)
                        {
                            if (dr.RowState != DataRowState.Deleted)
                            {
                                strDIFF_QTY = dr["DIFF_QTY"].ToString();
                                break;
                            }
                        }

                        if (ddlACStatus.Text == "1")
                            ReLoadPrice();

                        if (ErrorMsgLabel.Text != string.Empty)
                        {
                            return;
                        }


                        //把修改寫回資料庫
                        ArrayList parameterList = new ArrayList();
                        MaintainStoreDiff bco = new MaintainStoreDiff(ConnectionDB);
                        DbTransaction transaction = bco.GetTransaction();
                        CAMCommon bco1 = new CAMCommon();
                        string strReturn = "";

                        try
                        {
                            parameterList.Add(bco1.GetValueSetParameter(ViewState["CurrentID"].ToString(), "string", false)); //0
                            parameterList.Add(bco1.GetValueSetParameter(ddlIOType.Text, "string", false));                    //1
                            parameterList.Add(bco1.GetValueSetParameter(txtSignDate.Text, "string", false));                  //2
                            parameterList.Add(bco1.GetValueSetParameter(txtChainSourceNo.Text, "string", false));             //3
                            parameterList.Add(bco1.GetValueSetParameter(ddlDesc.Text, "string", false));                      //4
                            parameterList.Add(bco1.GetValueSetParameter(txtMemo.Text, "string", false));                      //5
                            parameterList.Add(Session["UID"].ToString());                                                     //6
                            parameterList.Add(bco1.GetValueSetParameter(strDIFF_QTY, "int", false));                          //7                        
                            parameterList.Add(bco1.GetValueSetParameter(txtBusDate.Text, "string", false));                   //8
                            string strItem = string.Empty;
                            string strPeriod = string.Empty;
                            for (int i = 0; i < DiffData.Rows.Count; i++)
                            {
                                if (DiffData.Rows[i].RowState != DataRowState.Deleted)
                                {
                                    strItem = DiffData.Rows[i]["Item"].ToString();
                                    strPeriod = DiffData.Rows[i]["Period"].ToString();
                                    break;
                                }
                            }
                            parameterList.Add(bco1.GetValueSetParameter(strItem, "string", false));     //9
                            parameterList.Add(bco1.GetValueSetParameter(strPeriod, "string", false));   //10

                            parameterList.Add(SLP_COL_DAYS.Text);
                            parameterList.Add(rblIsSchedule.Text);
                            parameterList.Add(slpPROMOTE_ID.Text);

                            strReturn = bco.UpdateStoreDiffMaster(transaction, parameterList);

                            if (strReturn != "")
                            {
                                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('更改失敗:" + strReturn + "');"), true);
                            }
                            else
                            {

                                for (int i = 0; i < DiffData.Rows.Count; i++)
                                {
                                    switch (DiffData.Rows[i].RowState)
                                    {
                                        case DataRowState.Deleted:
                                            DiffData.Rows[i].RejectChanges();
                                            parameterList.Clear();
                                            parameterList.Add(hidID.Value);
                                            parameterList.Add(DiffData.Rows[i]["Item"]);
                                            parameterList.Add(DiffData.Rows[i]["Period"]);
                                            bco.DeleteStoreDiffDetail(transaction, parameterList);
                                            DiffData.Rows[i].Delete();
                                            break;
                                    }
                                }

                                for (int i = 0; i < DiffData.Rows.Count; i++)
                                {
                                    switch (DiffData.Rows[i].RowState)
                                    {
                                        case DataRowState.Added:
                                        case DataRowState.Modified:
                                            parameterList.Clear();
                                            parameterList.Add(int.Parse(hidID.Value));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Item"].ToString(), "string", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Period"].ToString(), "string", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["PSS_ST_ACCEPT_QTY"].ToString(), "int", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["PSS_BACKWARD_QTY"].ToString(), "int", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["DIFF_QTY"].ToString(), "int", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["PDKIND"].ToString(), "int", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Cost"].ToString(), "double", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Cost_Dis_Rate"].ToString(), "double", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Cost_Dis"].ToString(), "double", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Price"].ToString(), "int", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["CHECK_REASON"].ToString(), "string", false));
                                            parameterList.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["CHECK_QTY"].ToString(), "int", false));
                                            parameterList.Add(Session["UID"].ToString());
                                            bco.UpdateDiff(transaction, parameterList);
                                            DiffData.Rows[i].RejectChanges();
                                            break;
                                    }
                                }
                                string strUPLOAD = "0";
                                if (txtChainSourceNo.Text.Trim() == "")
                                    strUPLOAD = "1";
                                else
                                    strUPLOAD = chkUpload.Checked ? "1" : "0";
                                bco.DoPatchProc(transaction, ViewState["CurrentID"].ToString(), Session["UID"].ToString(), strUPLOAD);

                                transaction.Commit();
                                OperationMode = OpMode.View;

                                SetControlStatus();
                                BindData();
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", null,
                                WUI_GMToolbarV.ClickAction.ButtonClick);
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, "", btnModify,
                                WUI_GMToolbarV.ClickAction.ButtonClick);
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Copy, true, string.Empty, btnCopy, WUI_GMToolbarV.ClickAction.ButtonClick);
                                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('更改成功');"), true);
                            }
                        }
                        catch
                        {
                            transaction.Rollback();
                            throw;
                        }
                    }
                    else
                    {
                        
                            //把修改寫回資料庫
                            ArrayList parameterList = new ArrayList();
                            MaintainStoreDiff bco = new MaintainStoreDiff(ConnectionDB);
                            DbTransaction transaction = bco.GetTransaction();
                            CAMCommon bco1 = new CAMCommon();
                            string strReturn = "";
                        try
                        {
                            parameterList.Add(bco1.GetValueSetParameter(ViewState["CurrentID"].ToString(), "string", false)); //0
                            parameterList.Add(bco1.GetValueSetParameter(txtChainSourceNo.Text, "string", false));             //1
                            parameterList.Add(bco1.GetValueSetParameter(txtMemo.Text, "string", false));                      //2
                            parameterList.Add(Session["UID"].ToString());                                                     //3

                            strReturn = bco.UpdateStoreDiffMemo(transaction, parameterList);

                            if (strReturn != "")
                            {
                                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('更改失敗:" + strReturn + "');"), true);
                            }
                            else
                            {
                                transaction.Commit();
                                OperationMode = OpMode.View;

                                SetControlStatus();
                                BindData();
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", null,
                                WUI_GMToolbarV.ClickAction.ButtonClick);
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, "", btnModify,
                                WUI_GMToolbarV.ClickAction.ButtonClick);
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Copy, true, string.Empty, btnCopy, WUI_GMToolbarV.ClickAction.ButtonClick);
                                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('更改成功');"), true);
                            }
                        }
                        catch
                        {
                            transaction.Rollback();
                            throw;
                        }
                    
                    }
                }
                catch (Exception ex)
                {
                    WaringLogProcess(ex.Message);
                    if (ex.Message.IndexOf("此入帳日年月己月結,請確認入帳日期是否正確?") > 0)
                    {
                        this.ErrorMsgLabel.Text = "此入帳日年月己月結,請確認入帳日期是否正確?";
                    }
                    else
                    {
                        this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
                    }
                }
                finally { Finally_Function(); }

                break;
        }
    }
コード例 #4
0
ファイル: CAM032.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void txt_STORE_Onblur()
    {
        if (OperationMode == OpMode.Add)
        {
            txtGroup.Text = "";
            txtRoute.Text = "";
            txtAcctUID.Text = "";
            txtStep.Text = "";
            txtProfit.Text = "";

            MaintainStoreDiff bco = new MaintainStoreDiff(ConnectionDB);
            ArrayList parameterList = new ArrayList();
            parameterList.Add(txtStore.Text);
            DataTable dt = bco.GetStoreInfo(parameterList);
            if (dt.Rows.Count > 0)
            {
                txtGroup.Text = dt.Rows[0]["GROUP_NO"].ToString();
                txtRoute.Text = dt.Rows[0]["ROUTE"].ToString();
                txtStep.Text = dt.Rows[0]["STEP"].ToString();
                txtAcctUID.Text = dt.Rows[0]["AC_UID"].ToString();
                txtProfit.Text = dt.Rows[0]["PROFIT_NO"].ToString();

                txtZ_O.Text = dt.Rows[0]["Z_O"].ToString();
                txtSAL_ID.Text = dt.Rows[0]["SAL_ID"].ToString();
            }
            GV_QtyRefresh();
        }
    }
コード例 #5
0
ファイル: CAM032.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void FillTextBoxData(string diffCode)
    {
        MaintainStoreDiff bco = new MaintainStoreDiff(ConnectionDB);
        ArrayList parameterList = new ArrayList();
        parameterList.Add(diffCode);
        DataTable dt = bco.GetDiffMaster(parameterList);
        txtGroup.Text = dt.Rows[0]["GROUP_NO"].ToString();
        txtStore.Text = dt.Rows[0]["STORE"].ToString();
        txtProfit.Text = dt.Rows[0]["Profit_No"].ToString();
        txtRoute.Text = dt.Rows[0]["ROUTE"].ToString();
        txtStep.Text = dt.Rows[0]["STEP"].ToString();
        txtAcctUID.Text = dt.Rows[0]["AC_UID"].ToString();
        ddlIOType.Text = dt.Rows[0]["OID_NO"].ToString();
        ddlCheckSource.Text = dt.Rows[0]["Check_Source"].ToString();
        txtSignDate.Text = (dt.Rows[0].IsNull("ST_BACK_DATE") ? "" : DateTime.Parse(dt.Rows[0]["ST_BACK_DATE"].ToString()).ToString("yyyy/MM/dd"));
        txtBusDate.Text = (dt.Rows[0].IsNull("DIFF_DATE") ? "" : DateTime.Parse(dt.Rows[0]["DIFF_DATE"].ToString()).ToString("yyyy/MM/dd"));
        txtStBackNo.Text = dt.Rows[0]["ST_BACK_NO"].ToString();
        txtChainSourceNo.Text = dt.Rows[0]["CHAN_SOURCE_NO"].ToString();
        txtDiffNo.Text = dt.Rows[0]["CODE"].ToString();
        txtPatchNo.Text = dt.Rows[0]["PATCH_CODE"].ToString();
        txtAdjustNo.Text = dt.Rows[0]["PATCH_ADJUST_NO"].ToString();
        chkUpload.Checked = dt.Rows[0]["PATCH_CHANGE_UPLOAD"].ToString() == "1" ? true : false;
        ddlDesc.Text = dt.Rows[0]["DESCTYPE"].ToString();
        txtMemo.Text = dt.Rows[0]["MEMO"].ToString();
        txtCostDisSum.Text = dt.Rows[0]["COST_DIS_SUM"].ToString();
        txtPriceSum.Text = dt.Rows[0]["PRICE_SUM"].ToString();
        txtQtySum.Text = dt.Rows[0]["QTY_SUM"].ToString();
        rblTaxType.Text = dt.Rows[0]["TAX_TYPE"].ToString();
        txtRootNo.Text = dt.Rows[0]["ROOT_NO"].ToString();
        rblIsSchedule.Text = dt.Rows[0]["IS_SCHEDULE"].ToString();
        ddlACStatus.Text = dt.Rows[0].IsNull("AC_STATUS") ? "1" : dt.Rows[0]["AC_STATUS"].ToString();
        txtACDateS.Text = dt.Rows[0]["AC_BALANCE_DATE_S"].ToString();
        txtACDate.Text = dt.Rows[0]["AC_BALANCE_DATE"].ToString();
        hidID.Value = dt.Rows[0]["ID"].ToString();

        txtZ_O.Text = dt.Rows[0]["Z_O"].ToString();
        txtSAL_ID.Text = dt.Rows[0]["SAL_ID"].ToString();
        slpCREATEUID.Text = dt.Rows[0]["CREATEUID"].ToString();
        slpUPDATEUID.Text = dt.Rows[0]["UPDATEUID"].ToString();
        hdfCREATEDATE.Value = dt.Rows[0]["CREATEDATE"].ToString();
        slpPROMOTE_ID.Text = dt.Rows[0]["PROMOTE_ID"].ToString();

        int i = int.Parse(rblIsSchedule.Text);
        string isSchedule = i >= 64 ? "1" : "0";
        InvoiceDateRange = dt.Rows[0]["INVOICE_DATE_RANGE"].ToString();
        SLP_COL_DAYS.Text = InvoiceDateRange;
        ItemKey = txtRootNo.Text + Convert.ToString(int.Parse(rblTaxType.Text)) + isSchedule + InvoiceDateRange;
    }
コード例 #6
0
ファイル: CAM032.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void BindData()
    {
        MaintainStoreDiff bco = new MaintainStoreDiff(ConnectionDB);
        ArrayList parameterList = new ArrayList();
        parameterList.Add(ViewState["CurrentID"].ToString());
        DataTable dt = bco.GetDiffDetail(parameterList);

        GridView1.DataSource = dt;
        GridView1.DataBind();
        DiffData = dt;
        TabContainer2.Visible = true;
        FillTextBoxData(ViewState["CurrentID"].ToString());
    }
コード例 #7
0
ファイル: CAM032.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void btnAddDetail_Click(object sender, EventArgs e)
    {
        try
        {
            DataRow[] dra2;
            string strYN = "N";
            MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
            txtCheckQty.Text = txtAdjQty.Text;

            if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(txtSignDate.Text)
                || string.IsNullOrEmpty(txtStBackNo.Text) || string.IsNullOrEmpty(txtBusDate.Text)
                || string.IsNullOrEmpty(ddlIOType.Text))
            {
                ErrorMsgLabel.Text = "店號、簽收日期、補帳日期、憑證單號、單據類型需有值";
                return;
            }

            if (DateTime.ParseExact(txtSignDate.Text, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture) > DateTime.Now)
            {
                ErrorMsgLabel.Text = "簽收日期不可大於系統日期";
                return;
            }

            if (DateTime.ParseExact(txtBusDate.Text, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture) > DateTime.Now)
            {
                ErrorMsgLabel.Text = "補帳日期不可大於系統日期";
                return;
            }

            if (RowMode == RowEditMode.Add)
            {
                DataRow[] dra1 = DiffData.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text));
                if (dra1.Length > 0)
                {
                    ErrorMsgLabel.Text = "品號及期別不能重複";
                    return;
                }

                if (txtReason.Text == "A21")
                {
                    MaintainStoreDiff bco1 = new MaintainStoreDiff(ConnectionDB);
                    ArrayList parameterList = new ArrayList();
                    parameterList.Add(txtItem.Text);
                    DataTable dt1 = bco1.DoCHECK_A21ITEM(parameterList);
                    if (dt1.Rows[0]["CNT"].ToString() == "0")
                    {
                        ErrorMsgLabel.Text = "此商品非A21所可使用的品號,無法新增。若要增加A21可用品項,請由代號碼Z9新增";
                        return;
                    }
                }
            }

            if (txtReason.Text.Length > 0)
            {
                if (txtReason.Text.Substring(0, 1) == "A")
                {
                    if (txtReason.Text == "A20" || txtReason.Text == "A21" || txtReason.Text == "A22" || txtReason.Text == "A23")
                    {
                        dra2 = DiffData.Select("CHECK_REASON not in ('A20','A21','A22','A23')");
                        if (dra2.Length > 0)
                        {
                            ErrorMsgLabel.Text = "調整原因分類需相同";
                            return;
                        }
                    }
                    else
                    {
                        dra2 = DiffData.Select("CHECK_REASON in ('A20','A21','A22','A23')");
                        if (dra2.Length > 0)
                        {
                            ErrorMsgLabel.Text = "調整原因分類需相同";
                            return;
                        }
                    }
                }
            }

            switch (RowMode)
            {
                case RowEditMode.Add:

                    if (txtCheckQty.Text.Length > 0 && txtReason.Text.Length > 0)
                    {
                        if (txtReason.Text.Substring(0, 1) == "A" && Convert.ToDecimal(txtCheckQty.Text) < 0)
                        {
                            IDataReader dr = bco.GetInvInfo(txtStore.Text, txtItem.Text, txtPeriod.Text);
                            if (!dr.Read())
                            {
                                dr.Close();
                                strYN = "Y";
                            }
                            else
                            {
                                if (Convert.ToDecimal(dr["ST_ACCEPT_QTY"]) < -1 * Convert.ToDecimal(txtCheckQty.Text) + Convert.ToDecimal(dr["BACKWARD_QTY"]))
                                {
                                    strYN = "Y";
                                }
                            }
                        }
                    }

                    break;

                case RowEditMode.Edit:
                    DataRow[] dra = DiffData.Select(string.Format("Item = '{0}' AND Period = '{1}'", txtItem.Text, txtPeriod.Text));

                    if (txtCheckQty.Text.Length > 0 && txtReason.Text.Length > 0)
                    {
                        if (txtReason.Text.Substring(0, 1) == "A" && Convert.ToDecimal(txtCheckQty.Text) < 0)
                        {
                            if (Convert.ToDecimal(dra[0]["PSS_ST_ACCEPT_QTY"]) < -1 * Convert.ToDecimal(txtCheckQty.Text) + Convert.ToDecimal(dra[0]["PSS_BACKWARD_QTY"]))
                            {
                                strYN = "Y";
                            }
                        }
                    }
                    break;
            }

            if (strYN == "Y")
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "if (confirm('進貨數<退貨數,是否仍要建立?')){this.disabled=true;__doPostBack('DoAddDetail','');}", true);
            }
            else
            {
                DoAddDetail();
            }

        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { Finally_Function(); }
    }
コード例 #8
0
ファイル: CAM032.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string strCODE;
        string strDIFF_QTY = "";
        try
        {
            if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(txtSignDate.Text)
                || string.IsNullOrEmpty(txtStBackNo.Text) || string.IsNullOrEmpty(txtBusDate.Text)
                || string.IsNullOrEmpty(ddlIOType.Text))
            {
                ErrorMsgLabel.Text = "店號、簽收日期、補帳日期、憑證單號、單據類型需有值";
                return;
            }

            if (DateTime.ParseExact(txtSignDate.Text, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture) > DateTime.Now)
            {
                ErrorMsgLabel.Text = "簽收日期不可大於系統日期";
                return;
            }

            if (DateTime.ParseExact(txtBusDate.Text, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture) > DateTime.Now)
            {
                ErrorMsgLabel.Text = "補帳日期不可大於系統日期";
                return;
            }


            DataTable dt = DiffData.GetChanges(DataRowState.Deleted);
            int inCount = (dt == null ? 0 : dt.Rows.Count);

            if (DiffData.Rows.Count > 0)
            {
                if (inCount == DiffData.Rows.Count)
                {
                    ErrorMsgLabel.Text = "需有明細資料";
                    return;
                }
            }
            else
            {
                ErrorMsgLabel.Text = "需有明細資料";
                return;
            }

            foreach (DataRow dr in DiffData.Rows)
            {
                if (dr.RowState != DataRowState.Deleted)
                {
                    strDIFF_QTY = dr["DIFF_QTY"].ToString();
                    break;
                }
            }

            string strCHAN_NO = "";
            MaintainStoreDiff bco = new MaintainStoreDiff(ConnectionDB);
            ArrayList parameterList = new ArrayList();
            parameterList.Add(txtStore.Text);
            DataTable dt1 = bco.GetStoreInfo(parameterList);
            if (dt1.Rows.Count > 0)
            {
                strCHAN_NO = dt1.Rows[0]["CHAN_NO"].ToString();
            }

            ReLoadPrice();
            if (ErrorMsgLabel.Text != string.Empty)
            {
                return;
            }

            parameterList.Clear();
            ArrayList masterParameter = new ArrayList();
            CAMCommon bco1 = new CAMCommon();
            masterParameter.Add(bco1.GetValueSetParameter(ddlACStatus.Text, "int", false));             //0
            masterParameter.Add(bco1.GetValueSetParameter(txtBusDate.Text, "string", false));           //1
            masterParameter.Add(bco1.GetValueSetParameter(txtSignDate.Text, "string", false));          //2
            masterParameter.Add(bco1.GetValueSetParameter(rblTaxType.Text, "int", false));              //3
            masterParameter.Add(bco1.GetValueSetParameter(txtRootNo.Text, "string", false));            //4
            masterParameter.Add(bco1.GetValueSetParameter(InvoiceDateRange, "string", false));          //5
            masterParameter.Add(bco1.GetValueSetParameter(rblIsSchedule.Text, "int", false));           //6
            masterParameter.Add(bco1.GetValueSetParameter(ddlIOType.Text, "string", false));            //7
            masterParameter.Add(bco1.GetValueSetParameter(ddlCheckSource.Text, "string", false));       //8
            masterParameter.Add(bco1.GetValueSetParameter(txtGroup.Text, "string", false));             //9
            masterParameter.Add(bco1.GetValueSetParameter(txtStore.Text, "string", false));             //10
            masterParameter.Add(bco1.GetValueSetParameter(txtRoute.Text, "string", false));             //11
            masterParameter.Add(bco1.GetValueSetParameter(txtStep.Text, "string", false));              //12
            masterParameter.Add(bco1.GetValueSetParameter(txtProfit.Text, "string", false));            //13
            masterParameter.Add(bco1.GetValueSetParameter(txtChainSourceNo.Text, "string", false));     //14
            masterParameter.Add(bco1.GetValueSetParameter(txtStBackNo.Text, "string", false));          //15
            masterParameter.Add(bco1.GetValueSetParameter(ddlDesc.Text, "string", false));              //16
            masterParameter.Add(bco1.GetValueSetParameter(txtMemo.Text, "string", false));              //17
            masterParameter.Add(bco1.GetValueSetParameter(Session["UID"].ToString(), "string", false)); //18
            masterParameter.Add(bco1.GetValueSetParameter(strDIFF_QTY, "int", false));                  //19

            string strITEM = string.Empty;
            string strPERIOD = string.Empty;

            for (int i = 0; i < DiffData.Rows.Count; i++)
            {
                if (DiffData.Rows[i].RowState != DataRowState.Deleted)
                {
                    ArrayList detailParameter = new ArrayList();
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Item"].ToString(), "string", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Period"].ToString(), "string", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["PSS_ST_ACCEPT_QTY"].ToString(), "int", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["PSS_BACKWARD_QTY"].ToString(), "int", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["DIFF_QTY"].ToString(), "int", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["PDKIND"].ToString(), "int", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Cost"].ToString(), "double", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Cost_Dis_Rate"].ToString(), "double", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Cost_Dis"].ToString(), "double", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["Price"].ToString(), "int", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["CHECK_REASON"].ToString(), "string", false));
                    detailParameter.Add(bco1.GetValueSetParameter(DiffData.Rows[i]["CHECK_QTY"].ToString(), "int", false));
                    detailParameter.Add(bco1.GetValueSetParameter(Session["UID"].ToString(), "string", false));
                    parameterList.Add(detailParameter);
                    if (strITEM == string.Empty)
                    {
                        strITEM = DiffData.Rows[i]["Item"].ToString();
                        strPERIOD = DiffData.Rows[i]["Period"].ToString();
                    }
                }
            }
            masterParameter.Add(strITEM);   //20
            masterParameter.Add(strPERIOD); //21
            masterParameter.Add(slpPROMOTE_ID.Text); //22
            //因為進貨&正項&金石堂&通路單號空值,需要把上傳打勾
            //所以在通路單號為空值時,直接傳上傳已勾選
            //之後在PKG_VDS_CAM03B.PATCH_PROC會判斷 進貨&正項&金石堂 這邊就不需要都一次判斷
            if (txtChainSourceNo.Text.Trim() == "")
                masterParameter.Add(bco1.GetValueSetParameter("1", "string", false));//23
            else
                masterParameter.Add(bco1.GetValueSetParameter(chkUpload.Checked ? "1" : "0", "string", false));//23

            string[] strReturn = bco.CreateStoreDiff(masterParameter, parameterList);

            if (strReturn[2] == "")
            {
                strCODE = strReturn[1];
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增成功');location.replace('CAM032.aspx?Code=" + Request["Code"].ToString() + "&Mode=View&ID=" + strCODE + "');"), true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增失敗:" + strReturn[2] + "');"), true);
            }

        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            if (ex.Message.IndexOf("此入帳日年月己月結,請確認入帳日期是否正確?") > 0)
            {
                this.ErrorMsgLabel.Text = "此入帳日年月己月結,請確認入帳日期是否正確?";
            }
            else
            {
                this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
            }
        }
        finally { Finally_Function(); }
    }