Пример #1
0
        protected override bool WfPreInsertDetailCheck(int pCurTabDetail)
        {
            vw_taxi020          masterModel = null;
            string              sqlSelect   = "";
            List <SqlParameter> sqlParms    = null;
            int chkCnts = 0;

            try
            {
                masterModel = DrMaster.ToItem <vw_taxi020>();
                if (GlobalFn.varIsNull(masterModel.tbe01) || masterModel.tbe01 == 0 ||
                    GlobalFn.varIsNull(masterModel.tbe02) || masterModel.tbe02 == 0 ||
                    GlobalFn.varIsNull(masterModel.tbe03) || masterModel.tbe03 == 0
                    )
                {
                    WfShowErrorMsg("請先新增單頭資料!");
                    return(false);
                }

                if (TabDetailList[0].DtSource.Rows.Count == 0)
                {
                    //檢查單頭資料是否存在
                    sqlSelect = @"SELECT COUNT(1) FROM tbe_tb
                                  WHERE tbe01=@tbe01
                                      AND tbe11=@tbe11
                                      AND NOT (@tbe02>tbe03
                                         OR tbe03<@tbe02)
                                ";
                    sqlParms  = new List <SqlParameter>();
                    sqlParms.Add(new SqlParameter("@tbe01", masterModel.tbe01));
                    sqlParms.Add(new SqlParameter("@tbe02", masterModel.tbe02));
                    sqlParms.Add(new SqlParameter("@tbe03", masterModel.tbe03));
                    sqlParms.Add(new SqlParameter("@tbe11", masterModel.tbe11));
                    chkCnts = GlobalFn.isNullRet(BoTax.OfGetFieldValue(sqlSelect, sqlParms.ToArray()), 0);
                    if (chkCnts > 1)
                    {
                        WfShowErrorMsg("該年月+申報別資料有重疊,請先查詢後再做修改!");
                        return(false);
                    }

                    WfSetControlsReadOnlyRecursion(ute_tbe01.Parent, true);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        protected override bool WfFormCheck()
        {
            vw_taxi020         masterModel = null;
            vw_taxi020s        detailModel = null;
            List <vw_taxi020s> detailList  = null;
            UltraGrid          uGrid;
            string             msg;
            Control            chkControl;
            string             chkColName;
            int iChkDetailTab, chkCnts;

            try
            {
                masterModel = DrMaster.ToItem <vw_taxi020>();
                #region 單頭資料檢查
                chkColName = "tbe01";       //發票年度
                chkControl = ute_tbe01;
                if (GlobalFn.varIsNull(masterModel.tbe01))
                {
                    this.uTab_Master.SelectedTab = uTab_Master.Tabs[0];
                    chkControl.Focus();
                    msg  = TabMaster.AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                    msg += "不可為空白";
                    errorProvider.SetError(chkControl, msg);
                    WfShowErrorMsg(msg);
                    return(false);
                }

                chkColName = "tbe02";       //發票月份-起
                chkControl = ute_tbe02;
                if (GlobalFn.varIsNull(masterModel.tbe02))
                {
                    this.uTab_Master.SelectedTab = uTab_Master.Tabs[0];
                    chkControl.Focus();
                    msg  = TabMaster.AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                    msg += "不可為空白";
                    errorProvider.SetError(chkControl, msg);
                    WfShowErrorMsg(msg);
                    return(false);
                }

                chkColName = "tbe03";       //發票月份-迄
                chkControl = ute_tbe03;
                if (GlobalFn.varIsNull(masterModel.tbe03))
                {
                    this.uTab_Master.SelectedTab = uTab_Master.Tabs[0];
                    chkControl.Focus();
                    msg  = TabMaster.AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                    msg += "不可為空白";
                    errorProvider.SetError(chkControl, msg);
                    WfShowErrorMsg(msg);
                    return(false);
                }
                #endregion

                #region 單身資料檢查
                iChkDetailTab = 0;
                uGrid         = TabDetailList[iChkDetailTab].UGrid;
                detailList    = TabDetailList[iChkDetailTab].DtSource.ToList <vw_taxi020s>();
                foreach (DataRow drTemp in TabDetailList[iChkDetailTab].DtSource.Rows)
                {
                    if (drTemp.RowState == DataRowState.Unchanged)
                    {
                        continue;
                    }

                    detailModel = drTemp.ToItem <vw_taxi020s>();
                    chkColName  = "tbe04";  //發票別
                    if (GlobalFn.varIsNull(detailModel.tbe04))
                    {
                        this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                        msg  = TabDetailList[iChkDetailTab].AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                        msg += "不可為空白";
                        WfShowErrorMsg(msg);
                        WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        return(false);
                    }

                    chkColName = "tbe05";   //發票別
                    if (GlobalFn.varIsNull(detailModel.tbe05))
                    {
                        this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                        msg  = TabDetailList[iChkDetailTab].AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                        msg += "不可為空白";
                        WfShowErrorMsg(msg);
                        WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        return(false);
                    }


                    chkColName = "tbe06";   //發票別
                    if (GlobalFn.varIsNull(detailModel.tbe06))
                    {
                        this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                        msg  = TabDetailList[iChkDetailTab].AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                        msg += "不可為空白!";
                        WfShowErrorMsg(msg);
                        WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        return(false);
                    }

                    //檢查發票別+聯數+簿號 在單身是否重覆
                    chkCnts = detailList.Where(p => GlobalFn.isNullRet(p.tbe04, "").ToUpper() == detailModel.tbe04.ToUpper() &&
                                               GlobalFn.isNullRet(p.tbe05, "").ToUpper() == detailModel.tbe05.ToUpper() &&
                                               p.tbe06 == detailModel.tbe06)
                              .Count();
                    if (chkCnts > 1)
                    {
                        this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                        msg = string.Format("發票別+聯數+簿號有重覆,請檢核!");
                        WfShowErrorMsg(msg);
                        WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        return(false);
                    }
                    //檢查key值是否存在
                    if (drTemp.RowState == DataRowState.Added)
                    {
                        chkColName = "tbe04";
                        if (BoTax.OfChkTbePKExists(detailModel.tbe01, detailModel.tbe02, detailModel.tbe03,
                                                   detailModel.tbe04, detailModel.tbe05, detailModel.tbe06) == true)
                        {
                            this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                            msg = string.Format("發票本已存在,請檢核!");
                            WfShowErrorMsg(msg);
                            WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        }
                    }

                    chkColName = "tbe07";   //起始發票號碼
                    if (GlobalFn.varIsNull(detailModel.tbe07))
                    {
                        this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                        msg  = TabDetailList[iChkDetailTab].AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                        msg += "不可為空白!";
                        WfShowErrorMsg(msg);
                        WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        return(false);
                    }

                    chkColName = "tbe08";   //截止發票號碼
                    if (GlobalFn.varIsNull(detailModel.tbe08))
                    {
                        this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                        msg  = TabDetailList[iChkDetailTab].AzaTbList.Where(p => p.aza03 == chkColName).Select(p => p.aza04).FirstOrDefault();
                        msg += "不可為空白!";
                        WfShowErrorMsg(msg);
                        WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        return(false);
                    }
                    //檢查字軌是否相同
                    if (detailModel.tbe07.ToUpper().Substring(0, 2) !=
                        detailModel.tbe08.ToUpper().Substring(0, 2))
                    {
                        this.uTab_Detail.SelectedTab = uTab_Detail.Tabs[iChkDetailTab];
                        msg = "發票字軌不同,請檢核!";
                        WfShowErrorMsg(msg);
                        WfFindErrUltraGridCell(uGrid, drTemp, chkColName);
                        return(false);
                    }
                }
                #endregion

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        //回傳值 true.通過驗證 false.未通過驗證,會把值還原
        protected override bool WfItemCheck(object sender, ItemCheckInfo e)
        {
            vw_taxi020         masterModel = null;
            vw_taxi020s        detailModel = null;
            List <vw_taxi020s> detailList = null;
            UltraGrid          uGrid = null;
            tba_tb             tbaModel = null;
            int begNo, endNo, chkBegNo, chkEndNo;
            int ChkCnts = 0;

            try
            {
                masterModel = DrMaster.ToItem <vw_taxi020>();
                #region 單頭-vw_taxi020
                if (e.Row.Table.Prefix.ToLower() == "vw_taxi020")
                {
                    switch (e.Column.ToLower())
                    {
                    case "tbe01":
                        if (GlobalFn.isNullRet(e.Value, "") == "")
                        {
                            return(true);
                        }
                        if (Convert.ToInt32(e.Value) <= 0)
                        {
                            WfShowErrorMsg("不可為0或負數!");
                            return(false);
                        }
                        break;

                    case "tbe11":       //申報別
                        if (GlobalFn.isNullRet(e.Value, "") == "")
                        {
                            return(true);
                        }
                        if (BoTax.OfChkTbaPKExists(GlobalFn.isNullRet(e.Value, "")) == false)
                        {
                            WfShowErrorMsg("無此申報別");
                            return(false);
                        }
                        tbaModel            = BoTax.OfGetTbaModel(e.Value.ToString());
                        DrMaster["tbe11_c"] = tbaModel.tba04;
                        break;

                    case "tbe02":
                        if (GlobalFn.isNullRet(e.Value, "") == "")
                        {
                            return(true);
                        }
                        if (Convert.ToInt32(e.Value) <= 0)
                        {
                            WfShowErrorMsg("不可為0或負數!");
                            return(false);
                        }
                        if (masterModel.tbe03 != 0 && Convert.ToInt32(e.Value) > masterModel.tbe03)
                        {
                            WfShowErrorMsg("發票年月起不得大於迄月!");
                            return(false);
                        }

                        break;

                    case "tbe03":
                        if (GlobalFn.isNullRet(e.Value, "") == "")
                        {
                            return(true);
                        }
                        if (Convert.ToInt32(e.Value) <= 0)
                        {
                            WfShowErrorMsg("不可為0或負數!");
                            return(false);
                        }
                        if (masterModel.tbe02 != 0 && Convert.ToInt32(e.Value) < masterModel.tbe02)
                        {
                            WfShowErrorMsg("發票年月起不得大於迄月!");
                            return(false);
                        }
                        break;
                    }
                }
                #endregion

                #region 單身-vw_taxi020s
                if (e.Row.Table.Prefix.ToLower() == "vw_taxi020s")
                {
                    uGrid       = sender as UltraGrid;
                    detailModel = e.Row.ToItem <vw_taxi020s>();
                    detailList  = e.Row.Table.ToList <vw_taxi020s>();

                    switch (e.Column.ToLower())
                    {
                    case "tbe04":       //發票別
                        if (GlobalFn.varIsNull(e.Value))
                        {
                            return(true);
                        }

                        if (!GlobalFn.varIsNull(e.Value) && !GlobalFn.varIsNull(detailModel.tbe05) && detailModel.tbe06 > 0 &&
                            detailList.Count > 1
                            )
                        {
                            if (WfChktbe04tbe05tbe06(e.Value.ToString(), detailModel.tbe05, detailModel.tbe06) == false)
                            {
                                return(false);
                            }
                        }
                        break;

                    case "tbe05":       //聯數
                        if (GlobalFn.varIsNull(e.Value))
                        {
                            return(true);
                        }
                        if (!GlobalFn.varIsNull(detailModel.tbe04) && !GlobalFn.varIsNull(e.Value) && detailModel.tbe06 > 0 &&
                            detailList.Count > 1
                            )
                        {
                            if (WfChktbe04tbe05tbe06(detailModel.tbe04, e.Value.ToString(), detailModel.tbe06) == false)
                            {
                                return(false);
                            }
                        }
                        break;

                    case "tbe06":       //簿號
                        if (GlobalFn.varIsNull(e.Value))
                        {
                            return(true);
                        }
                        if (!GlobalFn.varIsNull(detailModel.tbe04) && !GlobalFn.varIsNull(detailModel.tbe05) && Convert.ToInt32(detailModel.tbe06) > 0 &&
                            detailList.Count > 1
                            )
                        {
                            if (WfChktbe04tbe05tbe06(detailModel.tbe04, e.Value.ToString(), detailModel.tbe06) == false)
                            {
                                return(false);
                            }
                        }

                        break;

                    case "tbe07":    //起始發票號碼
                        if (GlobalFn.varIsNull(e.Value))
                        {
                            return(true);
                        }
                        if (GlobalFn.varIsNull(detailModel.tbe05))
                        {
                            return(true);
                        }
                        if (e.Value.ToString().Length != 10)
                        {
                            WfShowErrorMsg("發票號碼應為10碼!");
                            return(false);
                        }
                        if (!GlobalFn.isEnglishLettrs(e.Value.ToString().Substring(0, 2)))
                        {
                            WfShowErrorMsg("發票前兩碼僅能輸入英文字母!");
                            return(false);
                        }
                        if (!GlobalFn.isNumberCharachter(e.Value.ToString().Substring(2, 8)))
                        {
                            WfShowErrorMsg("發票後八碼僅能輸入數字!");
                            return(false);
                        }
                        if (!GlobalFn.varIsNull(detailModel.tbe08))
                        {
                            begNo = Convert.ToInt32(e.Value.ToString().Substring(2, 8));
                            endNo = Convert.ToInt32(detailModel.tbe08.Substring(2, 8));
                            if (e.Value.ToString().Substring(0, 2) != detailModel.tbe08.Substring(0, 2))
                            {
                                WfShowErrorMsg("發票字軌應相同,請檢核!");
                                return(false);
                            }

                            if (begNo > endNo)
                            {
                                WfShowErrorMsg("發票號碼,起不得大於迄!");
                                return(false);
                            }

                            //檢查明細中是否有發票重疊
                            ChkCnts = detailList.Where(p => !GlobalFn.varIsNull(p.tbe07) && !GlobalFn.varIsNull(p.tbe08) &&
                                                       p.tbe07.Substring(0, 2).ToUpper() == detailModel.tbe07.Substring(0, 2).ToUpper() &&
                                                       !(endNo <Convert.ToInt32(p.tbe07.Substring(2, 8)) || begNo> Convert.ToInt32(p.tbe08.Substring(2, 8)))
                                                       ).Count();
                            if (ChkCnts > 1)
                            {
                                WfShowErrorMsg("輸入發票有重覆,請檢核!");
                                return(false);
                            }
                        }
                        WfSetTotalCnts(e.Row);
                        break;

                    case "tbe08":    //截止發票號碼
                        if (GlobalFn.varIsNull(e.Value))
                        {
                            return(true);
                        }
                        if (GlobalFn.varIsNull(detailModel.tbe05))
                        {
                            return(true);
                        }
                        if (e.Value.ToString().Length != 10)
                        {
                            WfShowErrorMsg("發票號碼應為10碼!");
                            return(false);
                        }
                        if (!GlobalFn.isEnglishLettrs(e.Value.ToString().Substring(0, 2)))
                        {
                            WfShowErrorMsg("發票前兩碼僅能輸入英文字母!");
                            return(false);
                        }

                        if (!GlobalFn.isNumberCharachter(e.Value.ToString().Substring(2, 8)))
                        {
                            WfShowErrorMsg("發票後八碼僅能輸入數字!");
                            return(false);
                        }
                        if (!GlobalFn.varIsNull(detailModel.tbe08))
                        {
                            begNo = Convert.ToInt32(detailModel.tbe08.Substring(2, 8));
                            endNo = Convert.ToInt32(e.Value.ToString().Substring(2, 8));
                            if (e.Value.ToString().Substring(0, 2) != detailModel.tbe07.Substring(0, 2))
                            {
                                WfShowErrorMsg("發票字軌應相同,請檢核!");
                                return(false);
                            }

                            if (begNo > endNo)
                            {
                                WfShowErrorMsg("發票號碼,起不得大於迄!");
                                return(false);
                            }
                            //檢查明細中是否有發票重疊
                            ChkCnts = detailList.Where(p => !GlobalFn.varIsNull(p.tbe07) && !GlobalFn.varIsNull(p.tbe08) &&
                                                       p.tbe07.Substring(0, 2).ToUpper() == detailModel.tbe07.Substring(0, 2).ToUpper() &&
                                                       !(endNo <Convert.ToInt32(p.tbe07.Substring(2, 8)) || begNo> Convert.ToInt32(p.tbe08.Substring(2, 8)))
                                                       ).Count();
                            if (ChkCnts > 1)
                            {
                                WfShowErrorMsg("輸入發票有重覆,請檢核!");
                                return(false);
                            }
                        }
                        WfSetTotalCnts(e.Row);
                        break;
                    }
                }
                #endregion
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        protected override bool WfPickClickOnEditMode(object sender, string pColName, DataRow pDr)
        {
            try
            {
                vw_taxi020  masterModel = null;
                vw_taxi020s detailModel = null;
                //this.MsgInfoReturned = new MessageInfo();
                MessageInfo messageModel = new MessageInfo();
                #region 單頭-pick vw_stpt400
                if (pDr.Table.Prefix.ToLower() == "vw_taxi020")
                {
                    masterModel = DrMaster.ToItem <vw_taxi020>();
                    switch (pColName.ToLower())
                    {
                    case "tbe11":    //申報別
                        messageModel.ParamSearchList = new List <SqlParameter>();
                        messageModel.IsAutoQuery     = true;
                        WfShowPickUtility("p_tba", messageModel);
                        if (messageModel.Result == System.Windows.Forms.DialogResult.OK)
                        {
                            if (messageModel.DataRowList.Count > 0)
                            {
                                pDr[pColName] = GlobalFn.isNullRet(messageModel.DataRowList[0]["tba01"], "");
                            }
                            else
                            {
                                pDr[pColName] = "";
                            }
                        }
                        break;
                    }
                }
                #endregion

                #region 單身-pick vw_stpt400s
                if (pDr.Table.Prefix.ToLower() == "vw_taxi020s")
                {
                    //masterModel = DrMaster.ToItem<vw_stpt400>();
                    //detailModel = pDr.ToItem<vw_stpt400s>();
                    //switch (pColName.ToLower())
                    //{
                    //    case "sgb03"://料號
                    //        WfShowPickUtility("p_ica1", messageModel);
                    //        if (messageModel.Result == System.Windows.Forms.DialogResult.OK)
                    //        {
                    //            if (messageModel.DataRowList.Count > 0)
                    //                pDr[pColName] = GlobalFn.isNullRet(messageModel.DataRowList[0]["ica01"], "");
                    //            else
                    //                pDr[pColName] = "";
                    //        }
                    //        break;
                    //}
                }
                #endregion
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }