コード例 #1
0
ファイル: GroupPrice.cs プロジェクト: LavoTP/Arad.SMS.Gateway
        public static bool UpdateGroupPrice(Common.GroupPrice groupPrice, string agentRatio, bool isMainAdmin)
        {
            Business.GroupPrice groupPriceController = new Business.GroupPrice();
            decimal             currentRatio;
            decimal             newRatio;

            try
            {
                XDocument doc = new XDocument();
                XElement  element;
                XElement  root          = new XElement("NewDataSet");
                int       countOperator = Helper.GetInt(Helper.ImportData(agentRatio, "resultCount"));

                for (int counter = 0; counter < countOperator; counter++)
                {
                    element = new XElement("Table");
                    element.Add(new XElement("AgentID", Helper.ImportData(agentRatio, ("AgentID" + counter))));
                    currentRatio = Helper.ImportDecimalData(agentRatio, ("CurrentRatio" + counter));
                    newRatio     = Helper.ImportDecimalData(agentRatio, ("NewRatio" + counter));
                    if (newRatio < currentRatio && !isMainAdmin)
                    {
                        throw new Exception(Language.GetString("RatioNotValid"));
                    }

                    element.Add(new XElement("Ratio", Helper.ImportDecimalData(agentRatio, ("NewRatio" + counter))));
                    root.Add(element);
                }
                doc.Add(root);

                groupPrice.AgentRatio = doc.ToString();
                return(groupPriceController.UpdateGroupPrice(groupPrice));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }