Exemplo n.º 1
0
        public int AddChargeApplyDateTime(ChargeApplyDateTime _ChargeApplyDateTime)
        {
            try
            {
                _ChargeApplyDateTime.AuthStatusId = "U";
                _ChargeApplyDateTime.LastAction   = "ADD";
                _ChargeApplyDateTime.MakeDT       = System.DateTime.Now;
                var result = _IUoW.Repository <ChargeApplyDateTime>().Add(_ChargeApplyDateTime);
                #region Auth Log
                if (result == 1)
                {
                    _IAuthLogService = new AuthLogService();
                    long _outMaxSlAuthLogDtl = 0;
                    _IAuthLogService.AddAuthLog(_IUoW, null, _ChargeApplyDateTime, "ADD", "0001", "090102003", 1, "ChargeApplyDateTime", "MTK_CHG_APPLY_DT", "ChargeRuleId", _ChargeApplyDateTime.ChargeRuleId, "mtaka", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                }
                #endregion

                if (result == 1)
                {
                    _IUoW.Commit();
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddChargeRule(obj)", string.Empty);
                return(0);
            }
        }
Exemplo n.º 2
0
        public int AddChargeRule(ChargeRule _ChargeRule)
        {
            try
            {
                var _max = _IUoW.Repository <ChargeRule>().GetMaxValue(x => x.ChargeRuleId) + 1;
                _ChargeRule.ChargeRuleId       = _max.ToString().PadLeft(4, '0');
                _ChargeRule.PointTimeBalFlag   = "0";
                _ChargeRule.InsuffBalRefId     = "1";
                _ChargeRule.DeductPrdId        = "Y";
                _ChargeRule.DeductCondtionFlag = "0";
                //_ChargeRule.CustomerFilterAppFlag = "0";
                _ChargeRule.StaffAccExcFlag  = "0";
                _ChargeRule.ChargeAppConFlag = "0";
                _ChargeRule.TaxPenaltyRate   = 0;
                _ChargeRule.AuthStatusId     = "U";
                _ChargeRule.LastAction       = "ADD";
                _ChargeRule.MakeDT           = System.DateTime.Now;
                var result = _IUoW.Repository <ChargeRule>().Add(_ChargeRule);

                List <ChargeDeductCust> ListChargeDeductCust = new List <ChargeDeductCust>();
                var _maxCus = _IUoW.Repository <ChargeDeductCust>().GetMaxValue(x => x.SL) + 1;
                for (int i = 0; i < _ChargeRule.ListChargeDeductCust.Length; i++)
                {
                    ChargeDeductCust _ObjChargeDeductCust = new ChargeDeductCust();

                    _ObjChargeDeductCust.SL           = _maxCus.ToString().PadLeft(6, '0');
                    _ObjChargeDeductCust.ChargeRuleId = _ChargeRule.ChargeRuleId;
                    _ObjChargeDeductCust.CusCatId     = _ChargeRule.ListChargeDeductCust[i].CusCatId;
                    _ObjChargeDeductCust.AuthStatusId = "U";
                    _ObjChargeDeductCust.LastAction   = "ADD";
                    _ObjChargeDeductCust.MakeBy       = "mTaka";
                    _ObjChargeDeductCust.MakeDT       = System.DateTime.Now;
                    ListChargeDeductCust.Add(_ObjChargeDeductCust);
                    _maxCus += 1;
                }
                result = _IUoW.Repository <ChargeDeductCust>().AddRange(ListChargeDeductCust);

                List <ChargeApplyDateTime> ListChargeApplyDateTime = new List <ChargeApplyDateTime>();
                var _maxDT = _IUoW.Repository <ChargeApplyDateTime>().GetMaxValue(x => x.SL) + 1;
                for (int i = 0; i < _ChargeRule.ListChargeApplyDT.Length; i++)
                {
                    ChargeApplyDateTime _ObjChargeApplyDateTime = new ChargeApplyDateTime();

                    _ObjChargeApplyDateTime.SL           = _maxDT.ToString().PadLeft(6, '0');
                    _ObjChargeApplyDateTime.ChargeRuleId = _ChargeRule.ChargeRuleId;
                    _ObjChargeApplyDateTime.Saturday     = _ChargeRule.ListChargeApplyDT[i].Saturday == "True" ? "1" : "0";
                    _ObjChargeApplyDateTime.Sunday       = _ChargeRule.ListChargeApplyDT[i].Sunday == "True" ? "1" : "0";
                    _ObjChargeApplyDateTime.Monday       = _ChargeRule.ListChargeApplyDT[i].Monday == "True" ? "1" : "0";
                    _ObjChargeApplyDateTime.Tuesday      = _ChargeRule.ListChargeApplyDT[i].Tuesday == "True" ? "1" : "0";
                    _ObjChargeApplyDateTime.Wednesday    = _ChargeRule.ListChargeApplyDT[i].Wednesday == "True" ? "1" : "0";
                    _ObjChargeApplyDateTime.Thursday     = _ChargeRule.ListChargeApplyDT[i].Thursday == "True" ? "1" : "0";
                    _ObjChargeApplyDateTime.Friday       = _ChargeRule.ListChargeApplyDT[i].Friday == "True" ? "1" : "0";
                    _ObjChargeApplyDateTime.FromHour     = _ChargeRule.ListChargeApplyDT[i].FromHour.Split(':')[0].ToString();
                    _ObjChargeApplyDateTime.FromMinute   = _ChargeRule.ListChargeApplyDT[i].FromHour.Split(':')[1].ToString();
                    _ObjChargeApplyDateTime.ToHour       = _ChargeRule.ListChargeApplyDT[i].ToHour.Split(':')[0].ToString();
                    _ObjChargeApplyDateTime.ToMinute     = _ChargeRule.ListChargeApplyDT[i].ToHour.Split(':')[1].ToString();
                    _ObjChargeApplyDateTime.AuthStatusId = "U";
                    _ObjChargeApplyDateTime.LastAction   = "ADD";
                    _ObjChargeApplyDateTime.MakeBy       = "mTaka";
                    _ObjChargeApplyDateTime.MakeDT       = System.DateTime.Now;
                    ListChargeApplyDateTime.Add(_ObjChargeApplyDateTime);
                    _maxDT += 1;
                }
                result = _IUoW.Repository <ChargeApplyDateTime>().AddRange(ListChargeApplyDateTime);
                #region Auth Log
                if (result == 1)
                {
                    _IAuthLogService = new AuthLogService();
                    long _outMaxSlAuthLogDtl = 0;
                    result = _IAuthLogService.AddAuthLog(_IUoW, null, _ChargeRule, "ADD", "0001", _ChargeRule.FunctionId, 1, "ChargeRule", "MTK_CHG_RULE", "ChargeRuleId", _ChargeRule.ChargeRuleId, "mtaka", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                    if (result == 1 && ListChargeDeductCust != null && ListChargeDeductCust.Count() > 0)
                    {
                        result = _IAuthLogService.AddAuthLog(_IUoW, null, ListChargeDeductCust, "ADD", "0001", _ChargeRule.FunctionId, 0, "ChargeDeductCust", "MTK_CHG_DEDUCT_CUST", "SL", null, "mtaka", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                    }
                    if (result == 1 && ListChargeApplyDateTime != null && ListChargeApplyDateTime.Count() > 0)
                    {
                        result = _IAuthLogService.AddAuthLog(_IUoW, null, ListChargeApplyDateTime, "ADD", "0001", _ChargeRule.FunctionId, 0, "ChargeApplyDateTime", "MTK_CHG_APPLY_DT", "SL", null, "mtaka", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                    }
                }
                #endregion

                if (result == 1)
                {
                    _IUoW.Commit();
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddChargeRule(obj)", string.Empty);
                return(0);
            }
        }