Esempio n. 1
0
        public Models.VoucherResultDo GetVoucherList(Models.VoucherCriteriaDo criteria)
        {
            Models.VoucherResultDo result = new Models.VoucherResultDo();

            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Get_VoucherList]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(string), "VoucherTemplateID", criteria.VoucherTemplateID);
                command.AddParameter(typeof(string), "VoucherNumber", criteria.VoucherNumber);
                command.AddParameter(typeof(decimal), "VoucherValue", criteria.VoucherValue);
                command.AddParameter(typeof(string), "BrandCode", criteria.BrandCode);
                command.AddParameter(typeof(int), "BranchID", criteria.BranchID);
                command.AddParameter(typeof(DateTime), "CreateDateFrom", criteria.CreateDateFrom);
                command.AddParameter(typeof(DateTime), "CreateDateTo", criteria.CreateDateTo);
                command.AddParameter(typeof(DateTime), "StartDate", criteria.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", criteria.EndDate);
                command.AddParameter(typeof(DateTime), "PrintDateFrom", criteria.PrintDateFrom);
                command.AddParameter(typeof(DateTime), "PrintDateTo", criteria.PrintDateTo);
                command.AddParameter(typeof(DateTime), "UsedDateFrom", criteria.UsedDateFrom);
                command.AddParameter(typeof(DateTime), "UsedDateTo", criteria.UsedDateTo);
                command.AddParameter(typeof(bool), "IsUsed", criteria.IsUsed);
                command.AddParameter(typeof(bool), "IsExpired", criteria.IsExpired);
                command.AddParameter(typeof(bool), "IsVoid", criteria.IsVoid);
                command.AddParameter(typeof(bool), "IsActive", criteria.IsActive);
                command.AddParameter(typeof(DateTime), "CurrentDate", criteria.CurrentDate);

                Utils.SQL.ISQLDbParameter output        = command.AddSearchParameter(criteria);
                Utils.SQL.ISQLDbParameter ovoucher      = command.AddOutputParameter(typeof(int), "TotalVoucher");
                Utils.SQL.ISQLDbParameter ovouchervalue = command.AddOutputParameter(typeof(int), "TotalVoucherValue");

                result.Rows = command.ToList <Models.VoucherFSDo>();
                result.TotalRecordParameter(output);
            }));

            return(result);
        }
Esempio n. 2
0
        public Models.VoucherResultDo GetVoucherTemplateList(Models.VoucherCriteriaDo criteria)
        {
            Models.VoucherResultDo result = new Models.VoucherResultDo();

            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Get_VoucherTemplateList]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(string), "VoucherName", criteria.VoucherName);
                command.AddParameter(typeof(string), "VoucherNumber", criteria.VoucherNumber);
                command.AddParameter(typeof(decimal), "VoucherValue", criteria.VoucherValue);
                command.AddParameter(typeof(string), "BrandCode", criteria.BrandCode);
                command.AddParameter(typeof(int), "BranchID", criteria.BranchID);
                command.AddParameter(typeof(DateTime), "CreateDateFrom", criteria.CreateDateFrom);
                command.AddParameter(typeof(DateTime), "CreateDateTo", criteria.CreateDateTo);
                command.AddParameter(typeof(DateTime), "StartDate", criteria.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", criteria.EndDate);
                command.AddParameter(typeof(DateTime), "PrintDateFrom", criteria.PrintDateFrom);
                command.AddParameter(typeof(DateTime), "PrintDateTo", criteria.PrintDateTo);
                command.AddParameter(typeof(DateTime), "UsedDateFrom", criteria.UsedDateFrom);
                command.AddParameter(typeof(DateTime), "UsedDateTo", criteria.UsedDateTo);
                command.AddParameter(typeof(bool), "IsUsed", criteria.IsUsed);
                command.AddParameter(typeof(bool), "IsExpired", criteria.IsExpired);
                command.AddParameter(typeof(bool), "IsVoid", criteria.IsVoid);
                command.AddParameter(typeof(bool), "IsActive", criteria.IsActive);
                command.AddParameter(typeof(DateTime), "CurrentDate", criteria.CurrentDate);

                Utils.SQL.ISQLDbParameter output         = command.AddSearchParameter(criteria);
                Utils.SQL.ISQLDbParameter tvoucher       = command.AddOutputParameter(typeof(int), "TotalVoucher");
                Utils.SQL.ISQLDbParameter tvouchervalue  = command.AddOutputParameter(typeof(int), "TotalVoucherValue");
                Utils.SQL.ISQLDbParameter tfvoucher      = command.AddOutputParameter(typeof(int), "TotalFilterVoucher");
                Utils.SQL.ISQLDbParameter tfvouchervalue = command.AddOutputParameter(typeof(int), "TotalFilterVoucherValue");

                System.Collections.IList[] dbls = command.ToList(typeof(Models.VoucherFSDo), typeof(Models.VoucherBrandDo), typeof(Models.VoucherBranchDo));
                if (dbls != null)
                {
                    List <Models.VoucherFSDo> voucher           = dbls[0] as List <Models.VoucherFSDo>;
                    List <Models.VoucherBrandDo> voucherbrand   = dbls[1] as List <Models.VoucherBrandDo>;
                    List <Models.VoucherBranchDo> voucherbranch = dbls[2] as List <Models.VoucherBranchDo>;
                    if (voucher != null)
                    {
                        result.Rows = voucher;

                        if (voucherbrand != null)
                        {
                            foreach (Models.VoucherFSDo v in result.Rows)
                            {
                                v.Brands = voucherbrand.FindAll(x => x.VoucherTemplateID == v.VoucherTemplateID);
                            }
                        }

                        if (voucherbranch != null)
                        {
                            foreach (Models.VoucherFSDo v in result.Rows)
                            {
                                v.Branches = voucherbranch.FindAll(x => x.VoucherTemplateID == v.VoucherTemplateID);
                            }
                        }
                        if (tvoucher != null)
                        {
                            result.TotalVoucher = (int)tvoucher.Value;
                        }
                        if (tvouchervalue != null)
                        {
                            result.TotalVoucherValue = (int)tvouchervalue.Value;
                        }
                        if (tfvoucher != null)
                        {
                            result.TotalFilterVoucher = (int)tfvoucher.Value;
                        }
                        if (tfvouchervalue != null)
                        {
                            result.TotalFilterVoucherValue = (int)tfvouchervalue.Value;
                        }

                        result.TotalRecordParameter(output);
                    }
                }
            }));

            return(result);
        }