コード例 #1
0
        protected override bool WfPreInUpdateModeCheck()
        {
            vw_glat200          masterModel;
            string              sqlSelect   = "";
            List <SqlParameter> sqlParmList = null;
            int chkCnts = 0;

            try
            {
                masterModel = DrMaster.ToItem <vw_glat200>();

                if (!GlobalFn.varIsNull(masterModel.gea06))
                {
                    WfShowBottomStatusMsg("已拋轉傳票,不可修改!");
                    return(false);
                }

                if (masterModel.gea02 == "AR" && masterModel.gea03 == 1)    //應收帳款
                {
                    sqlSelect   = @"SELECT COUNT(1) FROM cea_tb WHERE cea01=@cea01 AND ceaconf<>'N' ";
                    sqlParmList = new List <SqlParameter>();
                    sqlParmList.Add(new SqlParameter("@cea01", masterModel.gea01));
                    chkCnts = GlobalFn.isNullRet(BoGla.OfGetFieldValue(sqlSelect, sqlParmList.ToArray()), 0);
                    if (chkCnts != 0)
                    {
                        WfShowBottomStatusMsg("單據非未確認狀態,不可修改!");
                        return(false);
                    }
                }

                if (masterModel.gea02 == "AR" && masterModel.gea03 == 2)    //應收帳款
                {
                    sqlSelect   = @"SELECT COUNT(1) FROM cfa_tb WHERE cfa01=@cfa01 AND cfaconf<>'N' ";
                    sqlParmList = new List <SqlParameter>();
                    sqlParmList.Add(new SqlParameter("@cea01", masterModel.gea01));
                    chkCnts = GlobalFn.isNullRet(BoGla.OfGetFieldValue(sqlSelect, sqlParmList.ToArray()), 0);
                    if (chkCnts != 0)
                    {
                        WfShowBottomStatusMsg("單據非未確認狀態,不可修改!");
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: FrmGlai110.cs プロジェクト: allen660412/YRERP
        //回傳值 true.通過驗證 false.未通過驗證,會把值還原
        protected override bool WfItemCheck(object sender, ItemCheckInfo e)
        {
            int                 chkCnts     = 0;
            vw_glai110          masterModel = null;
            vw_glai110s         detailModel = null;
            List <vw_glai110s>  detailList  = null;
            gba_tb              gbaModel    = null;
            UltraGrid           uGrid       = null;
            UltraGridRow        uGridRow    = null;
            string              sqlSelect   = "";
            List <SqlParameter> sqlParmList = null;

            try
            {
                masterModel = DrMaster.ToItem <vw_glai110>();
                if (e.Column.ToLower() != "gbd01" && GlobalFn.isNullRet(DrMaster["gbd01"], "") == "")
                {
                    WfShowErrorMsg("請先輸入上層部門!");
                    return(false);
                }
                #region 單頭-vw_glai110
                if (e.Row.Table.Prefix.ToLower() == "vw_glai110")
                {
                    switch (e.Column.ToLower())
                    {
                    case "gbd01":
                        if (GlobalFn.isNullRet(e.Value, "") == "")
                        {
                            e.Row["gbd01_c"] = "";
                            return(true);
                        }
                        var babModel = BoBas.OfGetBebModel(e.Value.ToString());
                        if (babModel == null)
                        {
                            WfShowErrorMsg("無此上層部門,請檢核!");
                            return(false);
                        }
                        if (babModel.bebvali != "Y")
                        {
                            WfShowErrorMsg("此上層部門已失效,請檢核!");
                            return(false);
                        }
                        if (WfChkGbd01Exists(e.Value.ToString()) == true)
                        {
                            WfShowErrorMsg("此上層部門已存在,請檢核!");
                            return(false);
                        }

                        e.Row["gbd01_c"] = babModel.beb03;
                        break;
                    }
                }
                #endregion

                #region 單身-vw_glai110s
                if (e.Row.Table.Prefix.ToLower() == "vw_glai110s")
                {
                    uGrid       = sender as UltraGrid;
                    uGridRow    = uGrid.ActiveRow;
                    detailModel = e.Row.ToItem <vw_glai110s>();
                    detailList  = e.Row.Table.ToList <vw_glai110s>();
                    switch (e.Column.ToLower())
                    {
                    case "gbd02":
                        if (GlobalFn.isNullRet(e.Value, "") == "")
                        {
                            e.Row["gbd02_c"] = "";
                            return(true);
                        }
                        var babModel = BoBas.OfGetBebModel(e.Value.ToString());
                        if (babModel == null)
                        {
                            WfShowErrorMsg("無此下層部門,請檢核!");
                            return(false);
                        }
                        if (babModel.bebvali != "Y")
                        {
                            WfShowErrorMsg("此下層部門已失效,請檢核!");
                            return(false);
                        }
                        if (masterModel.gbd01.ToUpper() == e.Value.ToString().ToUpper())
                        {
                            WfShowErrorMsg("不可與上層部門相同,請檢核!");
                            return(false);
                        }
                        chkCnts = detailList.Where(p => p.gbd02.ToUpper() == e.Value.ToString().ToUpper()).Count();
                        if (chkCnts > 1)
                        {
                            WfShowErrorMsg("下層部門不可重覆,請檢核!");
                            return(false);
                        }
                        sqlSelect   = "SELECT COUNT(1) FROM gbd_tb WHERE gbd02=@gbd02 AND gbd01<>@gbd01";
                        sqlParmList = new List <SqlParameter>();
                        sqlParmList.Add(new SqlParameter("@gbd01", masterModel.gbd01));
                        sqlParmList.Add(new SqlParameter("@gbd02", e.Value.ToString()));
                        chkCnts = GlobalFn.isNullRet(BoGla.OfGetFieldValue(sqlSelect, sqlParmList.ToArray()), 0);
                        if (chkCnts > 0)
                        {
                            WfShowErrorMsg("此下層部門已隸屬於其他上層部門,請檢核!");
                            return(false);
                        }
                        e.Row["gbd02_c"] = babModel.beb03;
                        break;
                    }
                }
                #endregion
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        //回傳值 true.通過驗證 false.未通過驗證,會把值還原
        protected override bool WfItemCheck(object sender, ItemCheckInfo e)
        {
            int                  iChkCnts    = 0;
            vw_glat300_1         masterModel = null;
            vw_glat300_1s        detailModel = null;
            List <vw_glat300_1s> detailList  = null;
            gba_tb               gbaModel    = null;
            UltraGrid            uGrid       = null;
            UltraGridRow         uGridRow    = null;
            int                  ChkCnts     = 0;
            string               sql         = "";
            List <SqlParameter>  sqlParmList = null;

            try
            {
                masterModel = DrMaster.ToItem <vw_glat300_1>();
                #region 單身-vw_glat300_1s
                if (e.Row.Table.Prefix.ToLower() == "vw_glat300_1s")
                {
                    uGrid       = sender as UltraGrid;
                    uGridRow    = uGrid.ActiveRow;
                    detailModel = e.Row.ToItem <vw_glat300_1s>();
                    detailList  = e.Row.Table.ToList <vw_glat300_1s>();
                    var bb = TabDetailList[0].DtSource.ToList <vw_glat300_1s>();
                    switch (e.Column.ToLower())
                    {
                    case "is_pick":    //項次
                        e.Row["gfh09"] = 0;
                        if (e.Value.ToString() == "Y")
                        {
                            WfSetControlReadonly(uGridRow.Cells["gfh09"], false);
                        }
                        else
                        {
                            WfSetControlReadonly(uGridRow.Cells["gfh09"], true);
                            WfSetSumGfb09();
                        }
                        break;

                    case "gfh09":       //沖帳金額
                        if (GlobalFn.varIsNull(e.Value))
                        {
                            WfShowErrorMsg("請輸入數字!");
                            return(false);
                        }
                        if (GlobalFn.isNullRet(e.Value, 0) < 0)
                        {
                            WfShowErrorMsg("金額不可小於0!");
                            return(false);
                        }
                        var sumGfh09 = detailList.Where(p => p.is_pick == "Y" && p.gfh09 >= 0)
                                       .Sum(p => p.gfh09);
                        if (masterModel.gfb07 < sumGfh09)
                        {
                            var bekModel = BoBas.OfGetBekModel(BaaModel.baa04);
                            WfShowErrorMsg(string.Format("輸入金額加總已超過{0},請檢核!",
                                                         GlobalFn.Round(masterModel.gfb07, bekModel.bek03).ToString())
                                           );
                            return(false);
                        }
                        //檢查 已沖+暫沖(DB)+輸入金額 是否有超過立帳金額
                        var availableMaxAmt = 0m;        //可輸入最高金額
                        var glat300aList    = _dtGlat300a.ToList <vw_glat300a>();
                        //可輸入金額=資料庫(立帳金額-暫沖)
                        availableMaxAmt = detailModel.gfg07 - detailModel.gfg08;
                        //可輸人金額 再減掉此傳票但不屬於該項次的金額加總
                        availableMaxAmt -= glat300aList.Where(p => p.gfh01 == detailModel.gfg01 && p.gfh02 == detailModel.gfg02 &&
                                                              p.gfh04 != masterModel.gfb02)
                                           .Sum(p => p.gfh09)
                        ;
                        //可輸入金額 再減掉資料庫中不屬於該傳票未過帳的金額加總
                        if (!GlobalFn.varIsNull(masterModel.gfb01))
                        {
                            sql         = @"SELECT SUM(gfh09) FROM gfh_tb
                                        WHERE gfhconf='N' AND gfh03<>@gfh03
                                          AND gfh01=@gfh01 AND gfh02=@gfh02
                                    ";
                            sqlParmList = new List <SqlParameter>();
                            sqlParmList.Add(new SqlParameter("@gfh01", detailModel.gfg01));
                            sqlParmList.Add(new SqlParameter("@gfh02", detailModel.gfg02));
                            sqlParmList.Add(new SqlParameter("@gfh03", masterModel.gfb01));
                            var sumTempGfh09 = GlobalFn.isNullRet(BoGla.OfGetFieldValue(sql, sqlParmList.ToArray()), 0m);
                            availableMaxAmt -= sumTempGfh09;
                        }

                        if (Convert.ToDecimal(e.Value) > availableMaxAmt)
                        {
                            var bekModel = BoBas.OfGetBekModel(BaaModel.baa04);
                            WfShowErrorMsg(string.Format("可輸入最大沖帳金額為{0} !",
                                                         GlobalFn.Round(availableMaxAmt, bekModel.bek03).ToString())
                                           );
                            return(false);
                        }
                        DrMaster["sum_gfh09"] = sumGfh09;
                        break;
                    }
                }
                #endregion
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }