Esempio n. 1
0
        bool ProductInRebate(RebateMaster pRebate, long pID, int pProdType, string pProdNo)
        {
            RebateMaster rebate;
            decimal      price = 0;

            try
            {
                foreach (Object obj in pRebate.RebateMasters.Keys)
                {
                    rebate = (RebateMaster)pRebate.RebateMasters[obj];
                    if (rebate.MasterID == pID && rebate.MasterType == 0)
                    {
                        if (rebate.ProdType == pProdType && rebate.ProdNo == pProdNo)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
Esempio n. 2
0
        decimal GetOtherPrice(RebateMaster pRebate, long pID, ref int saletype)
        {
            RebateMaster rebate;
            decimal      price = 0;

            try
            {
                foreach (Object obj in pRebate.RebateMasters.Keys)
                {
                    rebate = (RebateMaster)pRebate.RebateMasters[obj];
                    if (rebate.MasterID == pID && rebate.MasterType == 0)
                    {
                        if (rebate.ProdType == 9)
                        {
                            price    = rebate.CalcAmount;
                            saletype = rebate.CalcType;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(price);
        }
Esempio n. 3
0
        decimal GetPrice(DataRow pRow, RebateMaster pRebate, long pID)
        {
            RebateMaster rebate;
            decimal      price = 0;

            try
            {
                price = Static.ToDecimal(pRow["Price"]);
                foreach (Object obj in pRebate.RebateMasters.Keys)
                {
                    rebate = (RebateMaster)pRebate.RebateMasters[obj];

                    if (rebate.MasterID == pID && rebate.MasterType == 0)
                    {
                        RebateName = rebate.Name;
                        if (rebate.ProdType == Static.ToInt(pRow["ProdType"]) && rebate.ProdNo == Static.ToStr(pRow["ProdNo"]))
                        {
                            switch (rebate.CalcType)
                            {
                            case 1:
                                price = Math.Round(price * rebate.CalcAmount / 100, 2);
                                break;

                            case 0:
                                price = rebate.CalcAmount;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(price);
        }
Esempio n. 4
0
        public Result Init(DbConnections db)
        {
            Result res = new Result();

            try
            {
                EServ.Shared.Static.WriteToLogFile("Init RebateMaster ...");

                #region [ Init General List ]
                //res = HPro.DB.Main.DB202111(db,null);
//                string sql = @"
//                                select M.MasterID, M.MasterType,M.Name, D.ProdType, D.ProdNo, D.CalcType, D.CalcAmount
//                                from RebateMaster M
//                                left join RebateDetail D on M.MasterID = D.MasterID
//                                left join InvMain D on M.MasterID = D.MasterID";
                string sql = @"select M.MasterID, M.MasterType,M.Name, D.ProdType, D.ProdNo,C.Name as ProdName,D.CalcType, D.CalcAmount 
                                from RebateMaster M
                                left join RebateDetail D on M.MasterID = D.MasterID
                                left join invmain c on c.invid=d.prodno
                                where prodtype=0
                                union
                                select M.MasterID, M.MasterType,M.Name, D.ProdType, D.ProdNo, C.Name as ProdName ,D.CalcType, D.CalcAmount 
                                from RebateMaster M
                                left join RebateDetail D on M.MasterID = D.MasterID
                                left join servmain c on c.servid=d.prodno
                                where prodtype=1";

                res = db.ExecuteQuery("core", sql, enumCommandType.SELECT, "Txn50000x", null);

                if (res.ResultNo != 0)
                {
                    return(res);
                }
                if (res.Data == null)
                {
                    res.ResultNo   = 9110015;
                    res.ResultDesc = "RebateMaster уншихад алдаа гарлаа";
                    return(res);
                }
                foreach (DataRow DR in res.Data.Tables[0].Rows)
                {
                    RebateMaster rebate = new RebateMaster();
                    rebate.MasterID   = Static.ToLong(DR["MasterID"]);
                    rebate.MasterType = Static.ToInt(DR["MasterType"]);
                    rebate.Name       = Static.ToStr(DR["Name"]);
                    rebate.ProdType   = Static.ToInt(DR["ProdType"]);
                    rebate.ProdNo     = Static.ToStr(DR["ProdNo"]);
                    rebate.ProdName   = Static.ToStr(DR["ProdName"]);
                    rebate.CalcType   = Static.ToInt(DR["CalcType"]);
                    rebate.CalcAmount = Static.ToDecimal(DR["CalcAmount"]);
                    _RebateMasters.Add(rebate.MasterID + rebate.ProdType + rebate.ProdNo, rebate);
                }
                #endregion
                return(res);
            }
            catch (Exception ex)
            {
                res.ResultNo   = 9110015;
                res.ResultDesc = "Байгууллагын дансны бүтээгдэхүүний уншихад алдаа гарлаа" + ex.Message;

                EServ.Shared.Static.WriteToLogFile("Error.log", ex.Message + ex.Source + ex.StackTrace);

                return(res);
            }
        }