示例#1
0
    private void BindData()
    {
        string SessionIDName = "CAM051_" + PageTimeStamp.Value;
        MaintainStoreTransfer bco = new MaintainStoreTransfer(ConntionDB);

        DataTable dt = bco.QueryStoreTransfer(chkLike.Checked, txtGroup.Text, txtStore.Text,
                            txtProfit.Text, txtZO.Text, txtSalID.Text, txtAcctUID.Text,
                            ddlIOType.SelectedValue, txtTransferDate.StartDate, txtTransferDate.EndDate,
                            txtBusDate.StartDate, txtBusDate.EndDate, txtTransferNo.Text,
                            txtChainSourceNo.Text, txtInAcctNo.Text, rblTaxType.Text,
                            txtRootNo.Text, rblIsSchedule.SelectedValue, ddlACStatus.Text,
                            txtACBalanceDateS.Text, txtACBalanceDate.Text, txtItem.Text,
                            txtPeriod.Text, txtAdjQty.Text, txtAdjQty.Operator, TextBoxRowCountLimit.Text, SLP_CreateUID.Text, SLP_UpdateUID.Text,
                            slpPROMOTE_ID_S.Text, slpPROMOTE_ID_E.Text);

        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["CAM05CodeCollection"] = sc;
        }
        else
        {
            ErrorMsgLabel.Text = "查無資料";
        }
    }
示例#2
0
    private void Page_PreRender(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string mode = Request.QueryString["Mode"] ?? "";
            switch (mode)
            {
                case "Insert":
                    try
                    {
                        OperationMode = OpMode.Add;
                        SetControlStatus();
                        MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
                        string aplDate = bco.GetAPLDate();
                        txtBusDate.Text = aplDate;
                        ddlACStatus.Text = "1";
                    }
                    catch (Exception ex)
                    {
                        WaringLogProcess(ex.Message);
                        this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
                    }
                    finally { Finally_Function(); }

                    break;

                case "View":
                    try
                    {
                        if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                        {
                            ViewState["CurrentID"] = Request.QueryString["ID"];
                            BindData();
                        }
                        OperationMode = OpMode.View;
                        SetControlStatus();
                    }
                    catch (Exception ex)
                    {
                        WaringLogProcess(ex.Message);
                        this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
                    }
                    finally { Finally_Function(); }

                    break;

                default:
                    break;
            }
        }

        if ((OperationMode == OpMode.Add) || (OperationMode == OpMode.Edit))
        {
            Cal_GV1_Total();

            bool bA15 = false;
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                if (GridView1.Rows[i].Cells[7].Text.Trim() == "A15")
                {
                    bA15 = true;
                    break;
                }
            }
            if (bA15 == true)
            {
                ddlDesc.ReadOnly = false;
            }
            else
            {
                ddlDesc.Text = "";
                ddlDesc.ReadOnly = true;
            }
        }

        if ((OperationMode == OpMode.Add) || ((ddlACStatus.Text == "1") && (OperationMode == OpMode.Edit)))
        {
            ((TextBox)txtSignDate.FindControl("TextBoxCode")).Attributes["onblur"] = "if(vSignDate!=document.getElementById('ctl00_CPH_TabContainer1_TabPanel1_txtSignDate_TextBoxCode').value){vSignDate=document.getElementById('ctl00_CPH_TabContainer1_TabPanel1_txtSignDate_TextBoxCode').value;document.getElementById('" + this.btnReLoad.ClientID + "').click();}";
        }
    }
示例#3
0
    protected void DoAddDetail()
    {
        try
        {
            txtCheckQty.Text = txtAdjQty.Text;
            MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
            DataTable dtPriceInfo = null;

            //依第一筆商品明細,取得 稅別、群分類、是否檔期、票期
            //並更新對應欄位的值
            ArrayList parameterList = new ArrayList();
            parameterList.Add(Session.SessionID);
            parameterList.Add(txtStore.Text);
            parameterList.Add(txtItem.Text);
            parameterList.Add(txtPeriod.Text);
            parameterList.Add(Convert.ToDateTime(txtSignDate.Text).ToString("yyyyMMdd"));

            if (int.Parse(ddlIOType.Text) == 24)
                parameterList.Add(31);
            else if (int.Parse(ddlIOType.Text) == 25)
                parameterList.Add(33);
            else
                parameterList.Add(int.Parse(ddlIOType.Text));

            dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList);

            if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0")
            {
                ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString();
                return;
            }

            if (GridView1.Rows.Count == 0)
            {
                string taxType, rootNo, isSchedule;
                rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString();
                taxType = dtPriceInfo.Rows[0]["TaxType"].ToString();
                int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString());
                isSchedule = i >= 64 ? "1" : "0";
                InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString();
                SLP_COL_DAYS.Text = InvoiceDateRange;
                rblTaxType.Text = taxType;
                txtRootNo.Text = rootNo;
                rblIsSchedule.Text = isSchedule;
                ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange;

                slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString();

            }
            else
            {
                if (RowMode == RowEditMode.Add)
                {
                    int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString());
                    string isSchedule = i >= 64 ? "1" : "0";
                    if (dtPriceInfo.Rows[0]["RootNo"].ToString() +
                        dtPriceInfo.Rows[0]["TaxType"].ToString() +
                        isSchedule +
                        dtPriceInfo.Rows[0]["ChargeDate"].ToString() != ItemKey)
                    {
                        ErrorMsgLabel.Text = "稅別、群分類、是否檔期或票期不同無法新增";
                        return;
                    }
                    if (slpPROMOTE_ID.Text.Trim() != dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString().Trim())
                    {
                        ErrorMsgLabel.Text = "檔期編號不同無法新增";
                        return;
                    }
                }
            }

            //3.4 記錄在暫存的TABLE內,待按下新增時才會存到資料庫
            //itemName, stAcceptQty, backwardQty, listDisRate, listPrice, retailPrice
            //品名 進貨數 退貨數 牌價折扣率 牌價 零售價
            MaintainCodeFile BCO = new MaintainCodeFile(ConnectionDB);
            ArrayList parameters = new ArrayList();
            DataTable dt = null;

            switch (RowMode)
            {
                case RowEditMode.Add:
                    MaintainSKU sku = new MaintainSKU(ConnectionDB);
                    ArrayList list = new ArrayList();
                    list.Add(txtItem.Text);
                    DataTable dtItem = sku.QuerySKUByCode(list);
                    string itemName = dtItem.Rows[0]["ITEM_NAME"].ToString();
                    IDataReader dr = bco.GetInvInfo(txtStore.Text, txtItem.Text, txtPeriod.Text);
                    string stAcceptQty, backwardQty = "";
                    if (!dr.Read())
                    {
                        stAcceptQty = "0";
                        backwardQty = "0";
                    }
                    else
                    {
                        stAcceptQty = dr["ST_ACCEPT_QTY"].ToString();
                        backwardQty = dr["BACKWARD_QTY"].ToString();
                    }
                    dr.Close();

                    string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind;
                    listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString();
                    listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString();
                    retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString();
                    srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString();
                    priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString();

                    DataRow row = DiffData.NewRow();
                    row["Item"] = txtItem.Text;
                    row["ITEM_NAME"] = itemName;
                    row["Period"] = txtPeriod.Text;
                    row["PSS_ST_ACCEPT_QTY"] = stAcceptQty;
                    row["PSS_BACKWARD_QTY"] = backwardQty;
                    row["DIFF_QTY"] = txtAdjQty.Text;
                    if (txtCheckQty.Text.Length > 0)
                    {
                        row["CHECK_QTY"] = txtCheckQty.Text;
                    }
                    else
                    {
                        row["CHECK_QTY"] = System.DBNull.Value;
                    }
                    row["Cost"] = srcCostPrice;
                    row["Cost_Dis_Rate"] = decimal.Parse(listDisRate);
                    row["Cost_Dis"] = decimal.Parse(listPrice);
                    row["Price"] = decimal.Parse(retailPrice);
                    row["PDKIND"] = int.Parse(priceDiscountKind);
                    if (txtReason.Text.Length > 0)
                    {
                        row["CHECK_REASON"] = txtReason.Text;
                    }
                    else
                    {
                        row["CHECK_REASON"] = System.DBNull.Value;
                    }
                    parameters.Add("1"); /* 1是原因判斷的Category */
                    parameters.Add(txtReason.Text);
                    dt = BCO.QueryLineSwitch(MaintainCodeFile.QueryType.SLP,
                                             parameters
                                            );
                    row["EXPLAIN"] = dt.Rows[0]["EXPLAIN"].ToString();
                    DiffData.Rows.Add(row);
                    break;

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

                    parameters.Add("1"); /* 1是原因判斷的Category */
                    parameters.Add(txtReason.Text);
                    dt = BCO.QueryLineSwitch(MaintainCodeFile.QueryType.SLP,
                                             parameters
                                            );
                    if (txtReason.Text.Length > 0)
                    {
                        dra[0]["CHECK_REASON"] = txtReason.Text;
                    }
                    else
                    {
                        dra[0]["CHECK_REASON"] = System.DBNull.Value;
                    }

                    dra[0]["EXPLAIN"] = dt.Rows[0]["EXPLAIN"].ToString();
                    dra[0]["DIFF_QTY"] = txtAdjQty.Text;

                    if (txtCheckQty.Text.Length > 0)
                    {
                        dra[0]["CHECK_QTY"] = txtCheckQty.Text;
                    }
                    else
                    {
                        dra[0]["CHECK_QTY"] = System.DBNull.Value;
                    }
                    break;
            }

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

            txtItem.Text = txtPeriod.Text = txtAdjQty.Text = txtCheckQty.Text = txtReason.Text = "";
            pnlAddDiffItem1.Visible = false;
            btnAddDiffItem.Visible = true;
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { Finally_Function(); }
    }
示例#4
0
    //當門市修改時,要更新商品的進貨數和退貨數
    private void GV_QtyRefresh()
    {
        if (DiffData.Rows.Count > 0)
        {
            MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
            IDataReader dr;
            for (int i = 0; i < DiffData.Rows.Count; i++)
            {
                dr = bco.GetInvInfo(txtStore.Text, DiffData.Rows[i]["Item"].ToString(), DiffData.Rows[i]["Period"].ToString());
                string stAcceptQty, backwardQty = "";
                if (!dr.Read())
                {
                    DiffData.Rows[i]["PSS_ST_ACCEPT_QTY"] = "0";
                    DiffData.Rows[i]["PSS_BACKWARD_QTY"] = "0";
                }
                else
                {
                    DiffData.Rows[i]["PSS_ST_ACCEPT_QTY"] = dr["ST_ACCEPT_QTY"].ToString();
                    DiffData.Rows[i]["PSS_BACKWARD_QTY"] = dr["BACKWARD_QTY"].ToString();
                }
                dr.Close();

            }
            DiffData.AcceptChanges();
            GridView1.DataSource = DiffData;
            GridView1.DataBind();
            UpdatePanel1.Update();
        }
    }
示例#5
0
    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(); }
    }
示例#6
0
    private void ReLoadPrice()
    {
        try
        {

            if (txtStore.Text.Trim() != "" && txtSignDate.Text.Trim() != "" && this.ddlIOType.Text.Trim() != "")
            {
                MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
                DataTable dtPriceInfo = null;

                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    string strItem = GridView1.Rows[i].Cells[0].Text;
                    string strPeriod = GridView1.Rows[i].Cells[2].Text;
                    ArrayList parameterList = new ArrayList();
                    parameterList.Add(Session.SessionID);
                    parameterList.Add(txtStore.Text);
                    parameterList.Add(strItem);
                    parameterList.Add(strPeriod);
                    parameterList.Add(Convert.ToDateTime(txtSignDate.Text).ToString("yyyyMMdd"));

                    if (int.Parse(ddlIOType.Text) == 24)
                        parameterList.Add(31);
                    else if (int.Parse(ddlIOType.Text) == 25)
                        parameterList.Add(33);
                    else
                        parameterList.Add(int.Parse(ddlIOType.Text));

                    //dtPriceInfo = bco.GetPriceInfoList(true, parameterList);
                    dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList);

                    if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0")
                    {
                        ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString();
                        return;
                    }

                    if (i == 0)
                    {
                        string taxType, rootNo, isSchedule;
                        rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString();
                        taxType = dtPriceInfo.Rows[0]["TaxType"].ToString();
                        int iPriceDiscountKind = int.Parse(dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString());
                        isSchedule = iPriceDiscountKind >= 64 ? "1" : "0";
                        InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString();
                        SLP_COL_DAYS.Text = InvoiceDateRange;
                        rblTaxType.Text = taxType;
                        txtRootNo.Text = rootNo;
                        rblIsSchedule.Text = isSchedule;
                        ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange;

                        slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString();
                    }

                    string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind;
                    listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString();
                    listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString();
                    retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString();
                    srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString();
                    priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString();

                    DataRow[] dra = DiffData.Select(string.Format("Item = '{0}' AND Period = '{1}'", strItem, strPeriod));

                    dra[0]["Cost"] = srcCostPrice;
                    dra[0]["Cost_Dis_Rate"] = decimal.Parse(listDisRate);
                    dra[0]["Cost_Dis"] = decimal.Parse(listPrice);
                    dra[0]["Price"] = decimal.Parse(retailPrice);
                    dra[0]["PDKIND"] = int.Parse(priceDiscountKind);

                }
                DiffData.AcceptChanges();
            }
        }
        catch(Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
    }
示例#7
0
    protected void ButtonModify_Click(object sender, EventArgs e)
    {
        if (hidUPDATEUID.Value == "VDS1G")
        {
            ErrorMsgLabel.Text = "一代轉入資料無法更改";
            return;
        }

        int inCount = 0;
        switch (OperationMode)
        {
            case OpMode.Edit:
                try
                {
                    if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(slpTransferDate.Text)
                     || string.IsNullOrEmpty(txtTransferNo.Text) || string.IsNullOrEmpty(this.ddlIOType.Text))
                    {
                        ErrorMsgLabel.Text = "店號、調撥類別、調撥日期、憑證單號需有值";
                        return;
                    }
                    DataTable dt = TransferItem.GetChanges(DataRowState.Deleted);
                    inCount = (dt == null ? 0 : dt.Rows.Count);

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

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

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

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

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


                    //在編輯模式下把新增/修改的調撥商品寫到資料庫
                    ArrayList parameterList = new ArrayList();
                    MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
                    CAMCommon bco1 = new CAMCommon();
                    DbTransaction transaction = bco.GetTransaction();

                    try
                    {
                        parameterList.Add(ViewState["CurrentID"].ToString());
                        parameterList.Add(txtChainSourceNo.Text);
                        parameterList.Add(slpTransferDate.Text);
                        parameterList.Add(Session["UID"].ToString());
                        string strITEM = string.Empty;
                        string strPERIOD = string.Empty;
                        for (int i = 0; i < TransferItem.Rows.Count; i++)
                        {
                            if (TransferItem.Rows[i].RowState != DataRowState.Deleted)
                            {
                                strITEM = TransferItem.Rows[i]["Item"].ToString();
                                strPERIOD = TransferItem.Rows[i]["Period"].ToString();
                                break;
                            }
                        }
                        parameterList.Add(ddlIOType.Text);
                        parameterList.Add(strITEM);
                        parameterList.Add(strPERIOD);

                        parameterList.Add(SLP_COL_DAYS.Text);
                        parameterList.Add(txtIsSchedule.Text == "檔期" ? 1 : 0);
                        parameterList.Add(slpPROMOTE_ID.Text);

                        bco.UpdateStoreTransferMaster(transaction, parameterList);

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

                        for (int i = 0; i < TransferItem.Rows.Count; i++)
                        {
                            switch (TransferItem.Rows[i].RowState)
                            {
                                case DataRowState.Added:
                                case DataRowState.Modified:
                                    parameterList.Clear();
                                    parameterList.Add(hidID.Value);
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Item"].ToString(), "string", false));
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Period"].ToString(), "string", false));
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Adj_Qty"].ToString(), "string", false));
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["PriceDiscountKind"].ToString(), "int", false));
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Cost"].ToString(), "double", false));
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Cost_Dis_Rate"].ToString(), "double", false));
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Cost_Dis"].ToString(), "double", false));
                                    parameterList.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Price"].ToString(), "int", false));
                                    parameterList.Add(Session["UID"].ToString());
                                    bco.UpdateStoreTransfer(transaction, parameterList);
                                    TransferItem.Rows[i].RejectChanges();
                                    break;
                            }
                        }

                        bco.DoRecalTran(transaction, ViewState["CurrentID"].ToString());

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

                        SetControlStatus(OperationMode);
                        BindData();
                        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", null,
                        WUI_GMToolbarV.ClickAction.ButtonClick);
                        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, "", ButtonModify,
                        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;

            case OpMode.View:
                try
                {
                    //由檢視模式切換到編輯模式
                    OperationMode = OpMode.Edit;
                    txtChainSourceNo.ReadOnly = false;
                    txtChainSourceNo.CssClass = "";
                    btnAddTransferItem.Visible = false;
                    GridView1.Columns[11].Visible = false;
                    GridView1.Columns[12].Visible = false;

                    if (ddlACStatus.Text == "1")
                    {
                        //slpBusDate.IsRequired = true;
                        //slpBusDate.ReadOnly = false;
                        slpTransferDate.IsRequired = true;
                        slpTransferDate.ReadOnly = false;
                    }
                    btnCopy.Visible = false;
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Copy, false, string.Empty, null, WUI_GMToolbarV.ClickAction.ButtonClick);
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, "", ButtonModify,
                    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;
        }
    }
示例#8
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            int inCount = 0;
            if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(slpTransferDate.Text)
                || string.IsNullOrEmpty(txtTransferNo.Text) || string.IsNullOrEmpty(this.ddlIOType.Text))
            {
                ErrorMsgLabel.Text = "店號、調撥類別、調撥日期、憑證單號需有值";
                return;
            }

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

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

            if (string.Compare(slpTransferDate.Text, DateTime.Now.ToString("yyyy/MM/dd"), false) > 0)
            {
                ErrorMsgLabel.Text = "調撥日期不可大於系統日期";
                return;
            }

            if (string.Compare(slpBusDate.Text, DateTime.Now.ToString("yyyy/MM/dd"), false) > 0)
            {
                ErrorMsgLabel.Text = "入帳日期不可大於系統日期";
                return;
            }

            ReLoadPrice();

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

            ArrayList parameterList = new ArrayList();
            ArrayList masterParameter = new ArrayList();
            CAMCommon bco1 = new CAMCommon();

            masterParameter.Add(Session["UID"].ToString());
            masterParameter.Add(bco1.GetValueSetParameter(ddlACStatus.Text, "int", false));
            masterParameter.Add(bco1.GetValueSetParameter(txtRootNo.Text, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(rblTaxType.Text, "int", false));
            masterParameter.Add(txtIsSchedule.Text == "檔期" ? 1 : 0);
            masterParameter.Add(bco1.GetValueSetParameter(InvoiceDateRange, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(slpBusDate.Text, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(slpTransferDate.Text, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(txtTransferNo.Text, "string", false));

            //系統需判斷通路單號是否為空值 若是=>則將憑證單號資料一併存入通路單號欄位
            if (txtChainSourceNo.Text.Trim() != "")
                masterParameter.Add(bco1.GetValueSetParameter(txtChainSourceNo.Text, "string", false));
            else
                masterParameter.Add(bco1.GetValueSetParameter(txtTransferNo.Text, "string", false));

            masterParameter.Add(bco1.GetValueSetParameter(ddlIOType.Text, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(txtGroup.Text, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(txtProfit.Text, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(txtStore.Text, "string", false));
            string strMasterItem = string.Empty;
            string strMasterPeriod = string.Empty;

            for (int i = 0; i < TransferItem.Rows.Count; i++)
            {
                if (TransferItem.Rows[i].RowState != DataRowState.Deleted)
                {
                    ArrayList detailParameter = new ArrayList();
                    detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Item"].ToString(), "string", false));
                    detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Period"].ToString(), "string", false));
                    if (ddlIOType.Text == "25")
                    {
                        if (Convert.ToDecimal(TransferItem.Rows[i]["Adj_Qty"]) > 0)
                        {
                            detailParameter.Add(bco1.GetValueSetParameter(Convert.ToString(-1 * Convert.ToDecimal(TransferItem.Rows[i]["Adj_Qty"])), "double", false));
                        }
                        else
                        {
                            detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Adj_Qty"].ToString(), "double", false));
                        }
                    }
                    else
                    {
                        if (Convert.ToDecimal(TransferItem.Rows[i]["Adj_Qty"]) < 0)
                        {
                            detailParameter.Add(bco1.GetValueSetParameter(Convert.ToString(-1 * Convert.ToDecimal(TransferItem.Rows[i]["Adj_Qty"])), "double", false));
                        }
                        else
                        {
                            detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Adj_Qty"].ToString(), "double", false));
                        }
                    }
                    detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["PriceDiscountKind"].ToString(), "int", false));
                    detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Cost"].ToString(), "string", false));
                    detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Cost_Dis_Rate"].ToString(), "double", false));
                    detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Cost_Dis"].ToString(), "double", false));
                    detailParameter.Add(bco1.GetValueSetParameter(TransferItem.Rows[i]["Price"].ToString(), "double", false));
                    detailParameter.Add(Session["UID"].ToString());
                    parameterList.Add(detailParameter);
                    if (strMasterItem == string.Empty)
                    {
                        strMasterItem = TransferItem.Rows[i]["Item"].ToString();
                        strMasterPeriod = TransferItem.Rows[i]["Period"].ToString();
                    }
                }
            }
            masterParameter.Add(bco1.GetValueSetParameter(strMasterItem, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(strMasterPeriod, "string", false));
            masterParameter.Add(bco1.GetValueSetParameter(slpPROMOTE_ID.Text, "string", false));
            MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
            string strCODE = bco.CreateStoreTransfer(masterParameter, parameterList);

            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增成功');location.replace('CAM052.aspx?Code=" + Request["Code"].ToString() + "&Mode=View&ID=" + strCODE + "');"), 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(); }

    }
示例#9
0
    protected void txtTransferNo_Onblur()
    {
        ErrorMsgLabel.Text = "";

        MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
        ArrayList parameterList = new ArrayList();
        parameterList.Add(txtTransferNo.Text);
        DataTable dt = bco.GETTRANSFER_NO(parameterList);
        if (dt.Rows.Count > 0)
        {
            ErrorMsgLabel.Text = "憑證單號不可重覆";
        }
    }
示例#10
0
    private void Page_PreRender(object sender, EventArgs e)
    {
        string mode = Request.QueryString["Mode"] ?? "";
        if (!IsPostBack)
        {
            switch (mode)
            {
                case "Insert":
                    OperationMode = OpMode.Add;
                    SetControlStatus(OperationMode);
                    MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
                    string aplDate = bco.GetAPLDate();
                    slpBusDate.Text = aplDate;
                    ddlACStatus.Text = "1";
                    ddlIOType.Text = "";
                    txtStore.Focus();
                    break;

                case "View":
                    if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                    {
                        ViewState["CurrentID"] = Request.QueryString["ID"];
                        BindData();
                    }
                    if (ddlACStatus.Text != "1")
                    {
                        ButtonModify.Visible = false;
                    }
                    OperationMode = OpMode.View;
                    SetControlStatus(OperationMode);
                    break;

                default:
                    break;
            }
        }
        if ((OperationMode == OpMode.Add) || ((ddlACStatus.Text == "1") && (OperationMode == OpMode.Edit)))
        {
            ((TextBox)slpTransferDate.FindControl("TextBoxCode")).Attributes["onblur"] = "if(vTransferDate!=document.getElementById('ctl00_CPH_TabContainer1_TabPanel1_slpTransferDate_TextBoxCode').value){vTransferDate=document.getElementById('ctl00_CPH_TabContainer1_TabPanel1_slpTransferDate_TextBoxCode').value;document.getElementById('" + this.btnReLoad.ClientID + "').click();}";
        }

        Cal_Summary();
    }
示例#11
0
 protected void txt_STORE_Onblur()
 {
     if (OperationMode == OpMode.Add)
     {
         txtGroup.Text = "";
         txtZO.Text = "";
         txtAcctUID.Text = "";
         txtSalID.Text = "";
         txtProfit.Text = "";
         MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
         ArrayList parameterList = new ArrayList();
         parameterList.Add(txtStore.Text);
         IDataReader dr = bco.GetStoreInfo(parameterList);
         while (dr.Read())
         {
             txtGroup.Text = dr.IsDBNull(0) ? "" : dr.GetString(0);
             txtZO.Text = dr.IsDBNull(1) ? "" : dr.GetString(1);
             txtAcctUID.Text = dr.IsDBNull(2) ? "" : dr.GetString(2);
             txtSalID.Text = dr.IsDBNull(3) ? "" : dr.GetString(3);
             txtProfit.Text = dr.IsDBNull(4) ? "" : dr.GetString(4);
         }
         dr.Close();
         GV_PriceRefresh();
         GV_QtyRefresh();
     }
 }
示例#12
0
    private void FillTextBoxData()
    {
        MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
        IDataReader dr = bco.GetTransferRecord(ViewState["CurrentID"].ToString());
        dr.Read();
        txtGroup.Text = dr["Group_No"].ToString();
        txtStore.Text = dr["Store"].ToString();
        txtProfit.Text = dr["Profit_No"].ToString();
        txtZO.Text = dr["Z_O"].ToString();
        txtSalID.Text = dr["Sal_ID"].ToString();
        txtAcctUID.Text = dr["AC_UID"].ToString();
        ddlIOType.SelectedIndex = dr["Tran_Source"].ToString() == "24" ? 0 : 1;
        slpTransferDate.Text = DateTime.Parse(dr["Sign_Date"].ToString()).ToString("yyyy/MM/dd");
        slpBusDate.Text = DateTime.Parse(dr["Bus_Date"].ToString()).ToString("yyyy/MM/dd");
        txtTransferNo.Text = dr["TRANSFER_NO"].ToString();
        txtChainSourceNo.Text = dr["CHAN_SOURCE_NO"].ToString();
        txtInAcctNo.Text = dr["Code"].ToString();
        txtCostDisSum2.Text = Math.Abs(Convert.ToDecimal(dr["COST_DIS_SUM"])).ToString();
        txtPriceSum2.Text = Math.Abs(Convert.ToDecimal(dr["PRICE_SUM"])).ToString();
        txtQtySum2.Text = Math.Abs(Convert.ToDecimal(dr["QTY_SUM"])).ToString();
        rblTaxType.Text = dr["TAX_TYPE"].ToString();
        txtRootNo.Text = dr["ROOT_NO"].ToString();
        txtIsSchedule.Text = dr["IS_SCHEDULE"].ToString() == "1" ? "檔期" : "非檔期";
        ddlACStatus.Text = dr["AC_STATUS"].ToString() == "" ? "1" : dr["AC_STATUS"].ToString();
        txtACBalanceDateS.Text = dr["AC_BALANCE_DATE_S"].ToString();
        txtACBalanceDate.Text = dr["AC_BALANCE_DATE"].ToString();
        hidID.Value = dr["ID"].ToString();
        hidUPDATEUID.Value = dr["UPDATEUID"].ToString();
        InvoiceDateRange = dr["INVOICE_DATE_RANGE"].ToString();
        SLP_COL_DAYS.Text = InvoiceDateRange;
        ItemKey = txtRootNo.Text + rblTaxType.Text + dr["IS_SCHEDULE"].ToString() + InvoiceDateRange;

        SLP_CreateUID.Text = dr["CREATEUID"].ToString();
        SLP_UpdateUID.Text = dr["UPDATEUID"].ToString();
        hdfCREATEDATE.Value = dr["CREATEDATE"].ToString();
        slpPROMOTE_ID.Text = dr["PROMOTE_ID"].ToString();
        dr.Close();
    }
示例#13
0
 private void BindData()
 {
     MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
     IDataReader dr = bco.GetTransferDetail(ViewState["CurrentID"].ToString());
     DataTable dt = new DataTable();
     dt.Load(dr);
     dr.Close();
     dt.AcceptChanges();
     GridView1.DataSource = dt;
     GridView1.DataBind();
     TransferItem = dt;
     TabContainer2.Visible = true;
     FillTextBoxData();
 }
示例#14
0
    //新增明細
    protected void DoAddDetail()
    {
        try
        {
            if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(slpTransferDate.Text)
                || string.IsNullOrEmpty(txtTransferNo.Text) || string.IsNullOrEmpty(this.ddlIOType.Text))
            {
                ErrorMsgLabel.Text = "店號、調撥類別、調撥日期、憑證單號需有值";
                return;
            }

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

            MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
            DataTable dtPriceInfo = null;

            ArrayList parameterList = new ArrayList();
            parameterList.Add(Session.SessionID);
            parameterList.Add(txtStore.Text);
            parameterList.Add(txtItem.Text);
            parameterList.Add(txtPeriod.Text);
            parameterList.Add(Convert.ToDateTime(slpTransferDate.Text).ToString("yyyyMMdd"));

            if (int.Parse(ddlIOType.Text) == 24)
                parameterList.Add(41);
            else if (int.Parse(ddlIOType.Text) == 25)
                parameterList.Add(42);
            else
                parameterList.Add(int.Parse(ddlIOType.Text));

            dtPriceInfo = bco.GetPriceInfoList_PROMOTE(true, parameterList);

            if (dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString() == "0")
            {
                ErrorMsgLabel.Text = dtPriceInfo.Rows[0]["MESSAGE"].ToString();
                return;
            }

            if (GridView1.Rows.Count == 0)
            {
                //依第一筆商品明細,取得 稅別、群分類、是否檔期、票期
                //並更新對應欄位的值
                string taxType, rootNo, isSchedule;
                rootNo = dtPriceInfo.Rows[0]["RootNo"].ToString();
                taxType = dtPriceInfo.Rows[0]["TaxType"].ToString();
                int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString());
                isSchedule = i >= 64 ? "1" : "0";
                InvoiceDateRange = dtPriceInfo.Rows[0]["ChargeDate"].ToString();
                SLP_COL_DAYS.Text = InvoiceDateRange;
                rblTaxType.Text = taxType;
                txtRootNo.Text = rootNo;
                txtIsSchedule.Text = (isSchedule == "1" ? "檔期" : "非檔期");
                ItemKey = rootNo + taxType + isSchedule + InvoiceDateRange;
                slpPROMOTE_ID.Text = dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString();
            }
            else
            {
                if (RowMode == RowEditMode.Add)
                {
                    int i = int.Parse(dtPriceInfo.Rows[0]["PriceDiscountKind"].ToString());
                    string isSchedule = i >= 64 ? "1" : "0";
                    if (dtPriceInfo.Rows[0]["RootNo"].ToString() +
                        dtPriceInfo.Rows[0]["TaxType"].ToString() +
                        isSchedule +
                        dtPriceInfo.Rows[0]["ChargeDate"].ToString() != ItemKey)
                    {
                        ErrorMsgLabel.Text = "稅別、群分類、是否檔期或票期不同無法新增";
                        return;
                    }
                    if (slpPROMOTE_ID.Text.Trim() != dtPriceInfo.Rows[0]["PROMOTE_ID"].ToString().Trim())
                    {
                        ErrorMsgLabel.Text = "檔期編號不同無法新增";
                        return;
                    }
                }
            }

            //3.4 記錄在暫存的TABLE內,待按下新增時才會存到資料庫
            //itemName, stAcceptQty, backwardQty, listDisRate, listPrice, retailPrice
            //品名 進貨數 退貨數 牌價折扣率 牌價 零售價
            switch (RowMode)
            {
                case RowEditMode.Add:
                    MaintainSKU sku = new MaintainSKU(ConnectionDB);
                    ArrayList list = new ArrayList();
                    list.Add(txtItem.Text);
                    DataTable dtItem = sku.QuerySKUByCode(list);
                    string itemName = dtItem.Rows[0]["ITEM_NAME"].ToString();
                    IDataReader dr = bco.GetInvInfo(txtStore.Text, txtItem.Text, txtPeriod.Text);
                    string stAcceptQty, backwardQty = "";
                    if (!dr.Read())
                    {
                        stAcceptQty = "0";
                        backwardQty = "0";
                    }
                    else
                    {
                        stAcceptQty = dr["ST_ACCEPT_QTY"].ToString();
                        backwardQty = dr["BACKWARD_QTY"].ToString();
                    }
                    dr.Close();

                    string listDisRate, listPrice, retailPrice, srcCostPrice, priceDiscountKind;
                    listDisRate = dtPriceInfo.Rows[0]["LISTDISRATE"].ToString();
                    listPrice = dtPriceInfo.Rows[0]["LISTPRICE"].ToString();
                    retailPrice = dtPriceInfo.Rows[0]["SRC_RETAILPRICE"].ToString();
                    srcCostPrice = dtPriceInfo.Rows[0]["SRC_COSTPRICE"].ToString();
                    priceDiscountKind = dtPriceInfo.Rows[0]["PRICEDISCOUNTKIND"].ToString();

                    DataRow row = TransferItem.NewRow();
                    row["Item"] = txtItem.Text;
                    row["Name"] = itemName;
                    row["Period"] = txtPeriod.Text;
                    row["ST_Accept_Qty"] = stAcceptQty;
                    row["Backward_Qty"] = backwardQty;
                    row["Adj_Qty"] = (ddlIOType.Text == "25" ? -1 : 1) * Convert.ToDecimal(txtAdjQty.Text);
                    row["Cost"] = srcCostPrice;
                    row["Cost_Dis_Rate"] = decimal.Parse(listDisRate);
                    row["Cost_Dis"] = decimal.Parse(listPrice);
                    row["Price"] = decimal.Parse(retailPrice);
                    row["PriceDiscountKind"] = int.Parse(priceDiscountKind);
                    TransferItem.Rows.Add(row);
                    break;

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

                    dra[0]["Adj_Qty"] = (ddlIOType.Text == "25" ? -1 : 1) * Convert.ToDecimal(txtAdjQty.Text);
                    break;
            }

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

            txtItem.Text = txtPeriod.Text = txtAdjQty.Text = "";
            pnlAddTransferItem1.Visible = false;
            btnAddTransferItem.Visible = true;
            ddlIOType.Enabled = false;
            ddlIOType.CssClass = "readtxtbox";
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { Finally_Function(); }
    }
示例#15
0
    protected void btnAddDetail_Click(object sender, EventArgs e)
    {
        try
        {
            string strYN = "N";
            MaintainStoreTransfer bco = new MaintainStoreTransfer(ConnectionDB);
            if (string.IsNullOrEmpty(txtStore.Text) || string.IsNullOrEmpty(slpTransferDate.Text)
                || string.IsNullOrEmpty(txtTransferNo.Text) || string.IsNullOrEmpty(this.ddlIOType.Text))
            {
                ErrorMsgLabel.Text = "店號、調撥類別、調撥日期、憑證單號需有值";
                return;
            }

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

            switch (RowMode)
            {
                case RowEditMode.Add:

                    if (ddlIOType.Text == "25")//調出
                    {
                        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"]) < Convert.ToDecimal(txtAdjQty.Text) + Convert.ToDecimal(dr["BACKWARD_QTY"]))
                            {
                                strYN = "Y";
                            }
                        }
                    }
                    break;

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

                    if (ddlIOType.Text == "25")//調出
                    {
                        if (Convert.ToDecimal(dra[0]["ST_ACCEPT_QTY"]) < Convert.ToDecimal(txtAdjQty.Text) + Convert.ToDecimal(dra[0]["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(); }
    }