Example #1
0
        public Models.VoucherDo GetVoucherTemplate(Models.VoucherCriteriaDo criteria)
        {
            Models.VoucherDo result = null;

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

                command.AddParameter(typeof(int), "VoucherTemplateID", criteria.VoucherTemplateID);

                System.Collections.IList[] dbls = command.ToList(
                    typeof(Models.VoucherDo), typeof(Models.VoucherBrandDo), typeof(Models.VoucherBranchDo));
                if (dbls != null)
                {
                    List <Models.VoucherDo> dbvs         = dbls[0] as List <Models.VoucherDo>;
                    List <Models.VoucherBrandDo> dbvbs   = dbls[1] as List <Models.VoucherBrandDo>;
                    List <Models.VoucherBranchDo> dbvbhs = dbls[2] as List <Models.VoucherBranchDo>;
                    if (dbvs != null)
                    {
                        if (dbvs.Count > 0)
                        {
                            result          = dbvs[0];
                            result.Brands   = dbvbs;
                            result.Branches = dbvbhs;
                        }
                    }
                }
            }));

            return(result);
        }
Example #2
0
        public Models.UpdateVoucherResultDo CreateVoucherTemplate(Models.VoucherDo entity)
        {
            Models.UpdateVoucherResultDo result = new Models.UpdateVoucherResultDo();

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

                command.AddParameter(typeof(string), "NameLC", entity.VoucherName);
                command.AddParameter(typeof(string), "NameEN", entity.VoucherName);
                command.AddParameter(typeof(string), "VoucherType", entity.VoucherType);
                command.AddParameter(typeof(decimal), "VoucherValue", entity.VoucherValue);
                command.AddParameter(typeof(int), "Qty", entity.Qty);

                command.AddParameter(typeof(DateTime), "StartDate", entity.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", entity.EndDate);

                string brandXml = Utils.ConvertUtil.ConvertToXml_Store <Models.VoucherBrandDo>(entity.Brands);
                command.AddParameter(typeof(string), "BrandXML", brandXml);

                string branchXml = Utils.ConvertUtil.ConvertToXml_Store <Models.VoucherBranchDo>(entity.Branches);
                command.AddParameter(typeof(string), "BranchXML", branchXml);

                command.AddParameter(typeof(DateTime), "CreateDate", entity.CreateDate);
                command.AddParameter(typeof(string), "CreateUser", entity.CreateUser);

                result.Voucher = command.ToList <Models.VoucherDo>()[0];
            }));

            return(result);
        }
Example #3
0
        public Models.VoucherDo UpdateVoucherTemplate(Models.VoucherDo entity)
        {
            Models.VoucherDo result = null;

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

                command.AddParameter(typeof(int), "VoucherTemplateID", entity.VoucherTemplateID);
                command.AddParameter(typeof(string), "NameLC", entity.NameLC);
                command.AddParameter(typeof(string), "NameEN", entity.NameLC);
                command.AddParameter(typeof(string), "VoucherType", entity.VoucherType);
                command.AddParameter(typeof(decimal), "VoucherValue", entity.VoucherValue);
                command.AddParameter(typeof(int), "Qty", entity.Qty);
                command.AddParameter(typeof(DateTime), "StartDate", entity.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", entity.EndDate);
                command.AddParameter(typeof(bool), "FlagActivate", entity.FlagActivate);

                string brandXml = Utils.ConvertUtil.ConvertToXml_Store <Models.VoucherBrandDo>(entity.Brands);
                command.AddParameter(typeof(string), "BrandXML", brandXml);

                string branchXml = Utils.ConvertUtil.ConvertToXml_Store <Models.VoucherBranchDo>(entity.Branches);
                command.AddParameter(typeof(string), "BranchXML", branchXml);



                command.AddParameter(typeof(DateTime), "UpdateDate", entity.UpdateDate);
                command.AddParameter(typeof(string), "UpdateUser", entity.UpdateUser);

                System.Collections.IList[] dbls = command.ToList(
                    typeof(Models.VoucherDo), typeof(Models.VoucherBrandDo), typeof(Models.VoucherBranchDo));
                if (dbls != null)
                {
                    List <Models.VoucherDo> dbvs         = dbls[0] as List <Models.VoucherDo>;
                    List <Models.VoucherBrandDo> dbvbs   = dbls[1] as List <Models.VoucherBrandDo>;
                    List <Models.VoucherBranchDo> dbvbhs = dbls[2] as List <Models.VoucherBranchDo>;
                    if (dbvs != null)
                    {
                        if (dbvs.Count > 0)
                        {
                            result          = dbvs[0];
                            result.Brands   = dbvbs;
                            result.Branches = dbvbhs;
                        }
                    }
                }
            }));

            return(result);
        }
Example #4
0
        public void UpdateVoucherPrintTime(Models.VoucherDo entity)
        {
            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Update_VoucherPrintTime]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(int), "VoucherTemplateID", entity.VoucherTemplateID);
                string voucherXml = Utils.ConvertUtil.ConvertToXml_Store <Models.VoucherAtivateDo>(entity.Vouchers);
                command.AddParameter(typeof(string), "VoucherXML", voucherXml);

                command.AddParameter(typeof(DateTime), "UpdateDate", entity.UpdateDate);
                command.AddParameter(typeof(string), "UpdateUser", entity.UpdateUser);

                command.ExecuteScalar();
            }));
        }
Example #5
0
        public void GenerateVouhcer(Models.VoucherDo entity)
        {
            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Generate_Voucher]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(int), "VoucherTemplateID", entity.VoucherTemplateID);
                command.AddParameter(typeof(string), "VoucherType", entity.VoucherType);
                command.AddParameter(typeof(decimal), "VoucherValue", entity.VoucherValue);
                command.AddParameter(typeof(int), "Qty", entity.Qty);
                command.AddParameter(typeof(DateTime), "StartDate", entity.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", entity.EndDate);
                command.AddParameter(typeof(bool), "FlagActivate", entity.FlagActivate);

                command.AddParameter(typeof(DateTime), "CreateDate", entity.CreateDate);
                command.AddParameter(typeof(string), "CreateUser", entity.CreateUser);

                command.ExecuteScalar();
            }));
        }