Example #1
0
        /// <summary>
        /// 标详情页,获取回款汇总信息
        /// </summary>
        public void GetRepayedMsg(Guid projId)
        {
            List <SubscribeTotalInfo> repaylist = new SubscribeBLL().GetRepaymentInfo(projId);

            if (repaylist == null)
            {
                repaylist = new List <SubscribeTotalInfo>();
            }
            foreach (SubscribeTotalInfo item in repaylist)
            {
                switch (item.status)
                {
                case 1:
                    repayedAmount = SafeConvert.ToDecimal(item.Amount) + SafeConvert.ToDecimal(item.InterestAmount);
                    break;

                case 2:
                    overdueAmount = SafeConvert.ToDecimal(item.Amount) + SafeConvert.ToDecimal(item.InterestAmount);
                    break;

                case 3:
                    duerepayAmount = SafeConvert.ToDecimal(item.Amount) + SafeConvert.ToDecimal(item.InterestAmount);
                    break;
                }
            }


            //PrintJson("1", string.Format("{0}|{1}|{2}", ToolStatus.ConvertDetailWanMoney(repayedAmount),
            //        ToolStatus.ConvertDetailWanMoney(overdueAmount), ToolStatus.ConvertDetailWanMoney(duerepayAmount)));
        }
Example #2
0
        public virtual List <Message> EditValidate()
        {
            var result = new List <Message>();

            if (Count == 0)
            {
                return(result);
            }

            if (Count > 65535)
            {
                Count = 65535;
            }

            var quantity = SafeConvert.ToUInt32(Quantity);

            if (quantity > 0 && Count > quantity)
            {
                Count = CalculateAvailableQuantity(Count);
                result.Add(Message.Error($"Заказ превышает остаток на складе, товар будет заказан в количестве {Count}"));
            }

            if (Count > 1000)
            {
                result.Add(Message.Warning("Внимание! Вы заказали большое количество препарата."));
            }

            return(result);
        }
        public bool ingresoCredito()
        {
            CreditoClass creditoDB = new CreditoClass();

            creditoDB.TransacionId    = 1;
            creditoDB.NumeroTC        = SafeConvert.ToInt32(txtNumTC.Text);
            creditoDB.TipoTC          = "TC";
            creditoDB.Cuotas          = SafeConvert.ToInt32(numericCuotas.Value);
            creditoDB.NumeroOperacion = SafeConvert.ToInt32(txtNumOperacion.Text);
            creditoDB.Monto           = SafeConvert.ToInt32(txtMonto.Text);
            creditoDB.Autorizacion    = SafeConvert.ToInt32(txtAutorizacion.Text);

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("INSERT INTO bes_credito (transaction_id,num_tc,tipo_tc,cuotas,num_operacion,monto,autorizacion) VALUES ({0},{1},{2},{3},{4},{5},{6})",
                            creditoDB.TransacionId,
                            creditoDB.NumeroTC,
                            SqlHelper.Quote(creditoDB.TipoTC),
                            creditoDB.Cuotas,
                            creditoDB.NumeroOperacion,
                            creditoDB.Monto,
                            creditoDB.Autorizacion);

            int num = BL.DB.ExecuteNonQuery(sb.ToString());

            if (num > 0)
            {
                BL.MsgInfo("Se ha Ingresado una Transaccion");
                return(true);
            }

            return(false);
        }
Example #4
0
        private static void ApplyCounterQuestConditionProxyData(CounterQuestCondition counterQuestCondition, string s)
        {
            if (counterQuestCondition == null || s == null)
            {
                return;
            }
            var fields = s.Split(';');

            if (fields.Length < 5)
            {
                return;
            }
            counterQuestCondition.counterValueMode = (CounterValueConditionMode)SafeConvert.ToInt(fields[0]);
            var valueType = (QuestNumber.ValueType)SafeConvert.ToInt(fields[1]);

            switch (valueType)
            {
            case QuestNumber.ValueType.Literal:
                counterQuestCondition.requiredCounterValue = new QuestNumber(SafeConvert.ToInt(fields[2]));
                break;

            case QuestNumber.ValueType.CounterValue:
            case QuestNumber.ValueType.CounterMinValue:
            case QuestNumber.ValueType.CounterMaxValue:
                counterQuestCondition.requiredCounterValue              = new QuestNumber();
                counterQuestCondition.requiredCounterValue.valueType    = valueType;
                counterQuestCondition.requiredCounterValue.counterIndex = SafeConvert.ToInt(fields[3]);
                break;

            default:
                counterQuestCondition.requiredCounterValue = new QuestNumber();
                break;
            }
            counterQuestCondition.counterIndex = SafeConvert.ToInt(fields[4]);
        }
Example #5
0
        public IEnumerable <Store> GetStores()
        {
            try
            {
                var stores = new List <Store>();

                using (var connection = new OdbcConnection(this.ConnetionString))
                {
                    connection.Open();
                    var query   = $@"SELECT * FROM storeHDR";
                    var command = new OdbcCommand(query);
                    command.Connection = connection;

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            stores.Add(new Store
                            {
                                No   = SafeConvert.ToInt32(reader["No"]),
                                Name = SafeConvert.ToString(reader["Name"])
                            });
                        }
                    }

                    return(stores);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
        public IEnumerable <FormalizationPosition> Read()
        {
            var read = false;

            while (_reader.Read())
            {
                if (_reader.Name == "" && _reader.NodeType == XmlNodeType.Text && read)
                {
                    read = false;
                    var codeOkp = SafeConvert.ToUInt32(_reader.Value);
                    if (codeOkp == 0)
                    {
                        continue;
                    }
                    yield return(new FormalizationPosition {
                        NotCreateUnrecExp = true,
                        Status = UnrecExpStatus.NameForm,
                        Offer = new NewOffer {
                            CodeOKP = codeOkp
                        }
                    });
                }
                else if (_reader.Name == "CodeOKP")
                {
                    read = true;
                }
            }
        }
        /// <summary>
        /// 修改角色
        /// </summary>
        /// <param name="dto">传入角色信息</param>
        public void ModifyRole(RoleDto dto)
        {
            Role entity = _roleRepository.Get(SafeConvert.ToInt64(dto.Id));

            entity.Name = dto.Name;
            _roleRepository.Update(entity);
        }
        public virtual string Add(MasterData data)
        {
            var newMasterData = new TESTENTITY()
            {
                Id            = "123",
                STRING        = data.city,
                ISACTIVE      = SafeConvert.ToInt64(data.isActive),
                COMMENT       = data.comment,
                TESTENTITY2ID = data.combobox,
                REGISTERTIME  = data.registerTime,
            };

            var Id = testRepository.Insert(newMasterData).Id;

            //   testRepository.InsertOrUpdate(newMasterData);
            return(Id);

//            testRepository.Update(t => t.Id == "57627fde-0332-4db0-9036-ce3ec5e48496", t =>
//                new TESTENTITY()
//                {
//
//                    COMMENT = DateTime.Now.ToString("HH:mm:ss")
//                }
//            );
            //throw new Exception();
            //test2Repository.Update(t => t.Id == "123",t => new TESTENTITY2() {
            //     Text = DateTime.Now.ToString("HH:mm:ss tt zz")

            //});

            return(null);
        }
Example #9
0
        public IdentityRange GetIdentityRange(int accountType)
        {
            try
            {
                using (var connection = new OdbcConnection(this.ConnetionString))
                {
                    connection.Open();
                    var query   = $"SELECT * FROM AccSortCodes WHERE Code = {accountType}";
                    var command = new OdbcCommand(query);
                    command.Connection = connection;

                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            reader.Read();
                            return(new IdentityRange
                            {
                                Code = Convert.ToInt32(reader["Code"]),
                                Desc = SafeConvert.ToString(reader["Desc"]),
                                From = Convert.ToInt32(reader["From"]),
                                To = Convert.ToInt32(reader["To"])
                            });
                        }

                        return(null);
                    };
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
Example #10
0
        public override INode Factory(IFrame frame, int formerId)
        {
            if (frame.Payload.Length < 2)
            {
                return(null);
            }
            var s = Encoding.ASCII.GetString(frame.Payload, 0, frame.Payload.Length);

            if (s.StartsWith("G"))
            {
                STrace.Debug(typeof(Parser).FullName, formerId, "Ack Unex V1 sin dispositivo (GA)");
                return(DataProvider.Get(formerId, this));
            }
            if (frame.Payload[0] == 'H' && frame.Payload[1] == '0')
            {
                return(DataProvider.FindByIMEI(s.Substring(24, 16), this));
            }

            var did = "0";

            if (s.StartsWith("E"))
            {
                did = s.Substring(3, 5);
            }
            if (s.StartsWith("Q"))
            {
                did = s.Substring(2, 5);
            }
            if (s.StartsWith("K") && s.Length > 6)
            {
                did = s.Substring(1, 5);
            }
            return(DataProvider.Get(SafeConvert.ToInt32(did, 0), this));
        }
Example #11
0
        public static string GetDeviceType(object o)
        {
            int    deviceType = SafeConvert.ToInt32(o, 1);
            string str        = "ico-pc";

            switch (deviceType)
            {
            case 1:
                str = "ico-pc";
                break;

            case 2:
                str = "ico-android";
                break;

            case 3:
                str = "ico-apple";
                break;

            case 5:
                str = "ico-weixin";
                break;
            }
            return(str);
        }
Example #12
0
        private static void ApplyMessageQuestConditionProxyData(MessageQuestCondition messageQuestCondition, string s)
        {
            if (messageQuestCondition == null || s == null)
            {
                return;
            }
            var fields = s.Split(';');

            if (fields.Length < 7)
            {
                return;
            }
            messageQuestCondition.senderSpecifier = (QuestMessageParticipant)SafeConvert.ToInt(fields[0]);
            messageQuestCondition.senderID        = new StringField(fields[1]);
            messageQuestCondition.targetSpecifier = (QuestMessageParticipant)SafeConvert.ToInt(fields[2]);
            messageQuestCondition.targetID        = new StringField(fields[3]);
            messageQuestCondition.message         = new StringField(fields[4]);
            messageQuestCondition.parameter       = new StringField(fields[5]);
            var valueType = (MessageValueType)SafeConvert.ToInt(fields[6]);

            switch (valueType)
            {
            case MessageValueType.Int:
                messageQuestCondition.value = new MessageValue(SafeConvert.ToInt(fields[7]));
                break;

            case MessageValueType.String:
                messageQuestCondition.value = new MessageValue(fields[7]);
                break;

            default:
                messageQuestCondition.value = new MessageValue();
                break;
            }
        }
Example #13
0
 public void CopyTo(QuestNode node)
 {
     if (node == null)
     {
         Debug.LogWarning("Quest Machine: QuestNodeProxy.CopyTo destination is null.");
         return;
     }
     node.id             = new StringField(id);
     node.internalName   = new StringField(intName);
     node.nodeType       = type;
     node.isOptional     = optional;
     node.speaker        = new StringField(speaker);
     node.stateInfoList  = QuestStateInfoProxy.CreateList(states);
     node.conditionSet   = conds.CreateConditionSet();
     node.tagDictionary  = new TagDictionary(tags);
     node.childIndexList = new List <int>(childIdx);
     if (QuestProxy.includeCanvasRect && !string.IsNullOrEmpty(r))
     {
         var fields = r.Split(';');
         if (fields.Length == 4)
         {
             node.canvasRect = new Rect(SafeConvert.ToFloat(fields[0]), SafeConvert.ToFloat(fields[1]), SafeConvert.ToFloat(fields[2]), SafeConvert.ToFloat(fields[3]));
         }
     }
 }
Example #14
0
        private ConfigRequest ParseConfigRequest(String[] partes)
        {
            var crq = new ConfigRequest(Id, 0)
            {
                GeoPoint = null
            };

            var res = String.Format("H9;{0:D5}", Id);

            res += res.TakeWhile(b => b != '@').Aggregate <char, byte>(0, (current, b) => (byte)(current + b)).ToString("X2");

            crq.AddStringToSend(res);

            crq.StringParameters.Add(Indication.indicatedIMEI, partes[1]);
            crq.StringParameters.Add(Indication.indicatedSecret, partes[2]);
            crq.StringParameters.Add(Indication.indicatedFirmwareSignature, partes[3]);
            if (partes.Length > 4)
            {
                crq.IntegerParameters.Add(Indication.indicatedConfigurationRevision, SafeConvert.ToInt32(partes[4], -1));
            }
            if (partes.Length > 5)
            {
                crq.IntegerParameters.Add(Indication.indicatedCannedMessagesTableRevision, SafeConvert.ToInt32(partes[5], -1));
            }
            return(crq);
        }
        /// <summary>
        /// 修改权限
        /// </summary>
        /// <param name="dto">传入权限信息</param>
        public void ModifyPermission(PermissionManage.PermissionDto dto)
        {
            Permission entity = _permissionRepository.Get(SafeConvert.ToInt64(dto.ParentId));

            entity.MenuId = dto.MenuId;
            _permissionRepository.Update(entity);
        }
Example #16
0
        public void AddDebitoCredito(String all)
        {
            string[] datos        = all.Split('|');
            string   payment_type = "3"; // Por Defecto tiene Payment Type 3 (Credito)

            // [11] Abrev Tipo de Pago (CR = Credito y DB = Debito)
            if (datos[11] == "DB")
            {
                payment_type = "6"; // Cambia al Payment Type 6 (Debito)
            }

            // Obtiene el Payment ID Credito / Débito
            String paymentID = BL.DB.ExecuteScalar("SELECT id  FROM payments WHERE payment_type=" + payment_type + " LIMIT 1").ToString();

            BL.CurrentTransaction.AddPayment(int.Parse(paymentID), 0, 0, SafeConvert.ToDecimal(x_monto.Text));
            ArrayList payments = BL.CurrentTransaction.GetItems(typeof(TransPayment));

            foreach (TransPayment pay in payments)
            {
                if (pay.Data.Type.ToString() == "Debitor" || pay.Data.Type.ToString() == "CreditCard")
                {
                    if (pay.Data.Notes == "CLP" || pay.Data.Notes == null || pay.Data.Notes == "")
                    {
                        pay.Data.Notes = all;
                    }
                }
            }
        }
Example #17
0
 protected bool GetData()
 {
     if (!InfoType.ToText().IsIn("1;2"))
     {
         return(false);
     }
     if (InfoType == 1)
     {
         NewsBLL  bll   = new NewsBLL();
         NewsInfo model = bll.GetNewsInfo(NewsId.ToInt(0));
         if (model == null)
         {
             return(false);
         }
         strTitle = model.Title;
         Content  = model.Content;
         AddDate  = (model.AddDate ?? DateTime.Today).ToString("yyyy-MM-dd");
     }
     else if (InfoType == 2)
     {
         VideoBLL  bll   = new VideoBLL();
         VideoInfo model = bll.GetVideoInfo(SafeConvert.ToGuid(NewsId).Value);
         if (model == null)
         {
             return(false);
         }
         strTitle  = model.Title;
         AddDate   = (model.AddDate ?? DateTime.Today).ToString("yyyy-MM-dd");
         VideoPath = model.videopath;
     }
     return(true);
 }
Example #18
0
        public List <DbColumn> GetDbColumns(string database, string table)
        {
            List <DbColumn> list = new List <DbColumn>();
            DataTable       dt   = MySqlHelper.ExecuteDataset(ConnString, string.Format("SELECT * FROM `COLUMNS` WHERE TABLE_SCHEMA='{0}' AND TABLE_NAME='{1}';", database, table)).Tables[0];

            foreach (DataRow row in dt.Rows)
            {
                list.Add(new DbColumn
                {
                    ByteLength   = SafeConvert.ToInt32(row["CHARACTER_OCTET_LENGTH"]),
                    CharLength   = SafeConvert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]),
                    ColumnName   = row["COLUMN_NAME"].ToString(),
                    ColumnType   = row["DATA_TYPE"].ToString(),
                    IsIdentity   = row["EXTRA"].ToString() == "auto_increment",
                    IsNullable   = row["IS_NULLABLE"].ToString() == "YES",
                    IsPrimaryKey = row["COLUMN_KEY"].ToString() == "PRI",
                    Remark       = row["COLUMN_COMMENT"].ToString(),
                    //Precision = SafeConvert.ToInt32(row["NUMERIC_PRECISION"]),
                    Scale      = SafeConvert.ToInt32(row["NUMERIC_SCALE"]),
                    CSharpType = MySqlDbMap.CsharpType(row["DATA_TYPE"].ToString()),
                    JavaType   = MySqlDbMap.JavaType(row["DATA_TYPE"].ToString()),
                });
            }
            return(list);
        }
Example #19
0
 private static void ApplyTimerQuestConditionProxyData(TimerQuestCondition timerQuestCondition, string s)
 {
     if (timerQuestCondition == null || s == null)
     {
         return;
     }
     timerQuestCondition.counterIndex = SafeConvert.ToInt(s);
 }
        public void SetupForm(BLogic BL)
        {
            this.BL = BL;
            UserInterfaceHelper.TranslateForm(this);
            UserInterfaceHelper.CenterWindow(this);
            UserInterfaceHelper.VisibleForms.Add(this);

            DataTable bancos     = BL.DB.ExecuteDataTable("SELECT id, description FROM bes_banks WHERE status=0 ORDER BY description");
            int       contador   = bancos.Rows.Count;
            var       dataSource = new List <TestObject>();

            foreach (DataRow banco in bancos.Rows)
            {
                String description = banco["description"].ToString();
                int    id          = SafeConvert.ToInt32(banco["id"]);
                dataSource.Add(new TestObject()
                {
                    Name = description, Value = id
                });
            }
            this.x_banco_cheque.DataSource    = dataSource;
            this.x_banco_cheque.DisplayMember = "Name";
            this.x_banco_cheque.ValueMember   = "Value";
            this.x_banco_cheque.DropDownStyle = ComboBoxStyle.DropDownList;

            // Dia
            for (int i = 1; i <= 31; i++)
            {
                x_dia_cheque.Items.Add(i.ToString());
            }
            // Mes
            for (int i = 1; i <= 12; i++)
            {
                x_mes_cheque.Items.Add(i.ToString());
            }
            // Año
            for (int i = 2016; i <= 2018; i++)
            {
                x_anio_cheque.Items.Add(i.ToString());
            }
            // Colores --> Verde: #2a9800 - Rojo: #d74a2b - Naranja: #ffa909
            aceptar.BackColor  = ColorTranslator.FromHtml("#2a9800");
            cancelar.BackColor = ColorTranslator.FromHtml("#d74a2b");
            // Valores de Prueba por Defecto

            x_numero_cheque.Text = "0987654";
            //x_tasas_interes.Text = "2";
            rut_cheque.Text = "12345678A";
            x_nombre_completo_cheque.Text = "Domingo José Ilarreta Heydras";
            x_dia_cheque.Text             = DateTime.Now.ToString("dd");
            x_mes_cheque.Text             = DateTime.Now.ToString("MM");
            x_anio_cheque.Text            = DateTime.Now.ToString("yyyy");
            nro_cta_corriente.Text        = "09876543";
            x_cod_auth_cheque.Text        = "098768000000";

            x_monto.Text = BL.CurrentTransaction.FoodToPay().ToString();
        }
        public void SetupForm(BLogic BL)
        {
            this.BL = BL;
            //this.variableTID = variableTID;
            UserInterfaceHelper.CenterWindow(this);
            UserInterfaceHelper.VisibleForms.Add(this);

            txtMonto.Text = SafeConvert.ToString(BL.CurrentTransaction.FoodToPay());
        }
        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="dto">传入菜单信息</param>
        public void ModifyMenu(MenuDto dto)
        {
            Menu entity = _menuRepository.Get(SafeConvert.ToInt64(dto.Id));

            entity.Name = dto.Name;
            entity.Url  = dto.Url;
            entity.Icon = dto.Icon;
            _menuRepository.Update(entity);
        }
Example #23
0
        public Account GetAccount(int id)
        {
            try
            {
                using (var connection = new OdbcConnection(this.ConnetionString))
                {
                    connection.Open();
                    var query = $@"SELECT * FROM Accounts WHERE AccNo = {id}";

                    var command = new OdbcCommand(query);
                    command.Connection = connection;

                    using (var reader = command.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            return(null);
                        }
                        reader.Read();

                        return(new Account
                        {
                            Id = Convert.ToInt32(reader["AccNo"]),
                            ProviderId = SafeConvert.ToString(reader["AuxAccNo"]),
                            Name = SafeConvert.ToString(reader["Name"]),
                            Address = SafeConvert.ToString(reader["Address"]),
                            City = SafeConvert.ToString(reader["City"]),
                            ZipCode = SafeConvert.ToString(reader["ZipCode"]),
                            ComercialReduc = Convert.ToSingle(reader["Reduc100"]) / 100,
                            CreditLevel = Convert.ToSingle(reader["CreditLevel"]),
                            Email = SafeConvert.ToString(reader["Email"]),
                            OsekNo = SafeConvert.ToString(reader["OsekNo"]),
                            Fax = SafeConvert.ToString(reader["Fax"]),
                            Phone1 = SafeConvert.ToString(reader["Phone1"]),
                            Phone2 = SafeConvert.ToString(reader["Phone2"]),
                            SortCode1 = Convert.ToInt32(reader["SortCode1"]),
                            SortCode2 = Convert.ToInt32(reader["SortCode2"]),
                            SortCode3 = Convert.ToInt32(reader["SortCode34"]),
                            SortCode4 = 0,
                            SortCode5 = Convert.ToInt32(reader["SortCode5"]),
                            SortCode6 = Convert.ToInt32(reader["SortCode6"]),
                            VatFlag = SafeConvert.ToString(reader["VatFlag"]),
                            CreatedDate = FromPervasiveDate(Convert.ToDouble(reader["Cdate"])),
                            UpdatedDate = FromPervasiveDate(Convert.ToDouble(reader["Udate"])),
                            RecurringPayment = Convert.ToSingle(reader["CreditDays"]),
                            Balance = Convert.ToSingle(reader["GrandTotal"]),
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
        private float[] GetPersonalityTraits(List <string> row)
        {
            var traits = new float[db.personalityTraitDefinitions.Length];

            for (int i = 0; i < db.personalityTraitDefinitions.Length; i++)
            {
                traits[i] = SafeConvert.ToFloat(GetColumn(row, prefs.firstPersonalityTraitColumn + i));
            }
            return(traits);
        }
Example #25
0
        public void TestNoOverflows()
        {
            XAssert.AreEqual(0, SafeConvert.ToInt32(double.MaxValue), "bigInt");
            XAssert.AreEqual(0, SafeConvert.ToInt32(double.MinValue), "smallInt");
            XAssert.AreEqual(15, SafeConvert.ToInt32(15.3234));

            XAssert.AreEqual(0, SafeConvert.ToLong(double.MaxValue), "bigLong");
            XAssert.AreEqual(0, SafeConvert.ToLong(double.MinValue), "smallLong");
            XAssert.AreEqual(15, SafeConvert.ToLong(15.3234));
        }
Example #26
0
        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="dto">传入用户信息</param>
        public void ModifyUser(UserManage.UserDto dto)
        {
            User entity = _userRepository.Get(SafeConvert.ToInt64(dto.Id));

            entity.Email    = dto.Email;
            entity.RealName = dto.RealName;
            entity.Phone    = dto.Phone;
            entity.RoleId   = dto.RoleId;
            _userRepository.Update(entity);
        }
Example #27
0
 public Reject(FormalizationPosition position)
 {
     Product      = position.PositionName;
     ProductId    = (uint?)position.ProductId;
     Producer     = position.FirmCr;
     ProducerId   = (uint?)position.CodeFirmCr;
     Series       = position.Offer.Code;
     LetterNo     = position.Offer.CodeCr;
     LetterDate   = SafeConvert.ToDateTime(position.Offer.Note);
     CauseRejects = position.Offer.Doc;
 }
        /// <summary>
        /// 分配权限
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="permissionIds"></param>
        public void DistributePermission(long?roleId, long?[] permissionIds)
        {
            Role entity      = _roleRepository.Get(SafeConvert.ToInt64(roleId));
            var  permissions = _permissionRepository.Table.Where(t => permissionIds.Contains(t.Id));

            entity.Permissions.Clear();
            entity.Permissions = permissions.ToList();
            _roleRepository.Update(entity);

            //WriteOperateLog(LogType.信息, LogModule.权限管理, "角色[{0}]分配权限成功!", entity.RoleName);
        }
        /// <summary>
        /// Производится вставка данных в таблицу Core
        /// </summary>
        public void InsertToCore(FormalizationPosition position, Cost[] costs)
        {
            var quantity = GetFieldValueObject(PriceFields.Quantity);
            var core     = new NewOffer {
                Code             = GetFieldValue(PriceFields.Code),
                CodeCr           = GetFieldValue(PriceFields.CodeCr),
                Unit             = GetFieldValue(PriceFields.Unit),
                Volume           = GetFieldValue(PriceFields.Volume),
                Quantity         = quantity is DBNull ? null : quantity.ToString(),
                Note             = GetFieldValue(PriceFields.Note),
                Doc              = (string)GetFieldValueObject(PriceFields.Doc),
                Junk             = (bool)GetFieldValueObject(PriceFields.Junk),
                Await            = (bool)GetFieldValueObject(PriceFields.Await),
                VitallyImportant = (bool)GetFieldValueObject(PriceFields.VitallyImportant),
                MinBoundCost     = GetDecimalValue(PriceFields.MinBoundCost),
                MaxBoundCost     = GetDecimalValue(PriceFields.MaxBoundCost),
                OrderCost        = GetDecimalValue(PriceFields.OrderCost),
                MinOrderCount    = GetUintOrDefault(PriceFields.MinOrderCount),
                RequestRatio     = GetUintOrDefault(PriceFields.RequestRatio),
                RegistryCost     = GetDecimalValue(PriceFields.RegistryCost),
                Nds              = GetUintOrDefault(PriceFields.Nds),
                CodeOKP          = GetUintOrDefault(PriceFields.CodeOKP),
                EAN13            = SafeConvert.ToUInt64(GetFieldValue(PriceFields.EAN13)),
                Series           = GetFieldValue(PriceFields.Series),
                ProducerCost     = GetDecimalValue(PriceFields.ProducerCost),
                OptimizationSkip = (bool)GetFieldValueObject(PriceFields.OptimizationSkip)
            };

            if (quantity is int)
            {
                core.QuantityAsInt = (int)quantity;
            }

            var    rawPeriodValue = GetFieldValueObject(PriceFields.Period);
            string periodValue;

            //если получилось преобразовать в дату, то сохраняем в формате даты
            if (rawPeriodValue is DateTime)
            {
                periodValue = ((DateTime)rawPeriodValue).ToString("dd'.'MM'.'yyyy");
            }
            else
            {
                //Если не получилось преобразовать, то смотрим на "сырое" значение поле, если оно не пусто, то пишем в базу
                periodValue = GetFieldRawValue(PriceFields.Period);
                if (String.IsNullOrEmpty(periodValue))
                {
                    periodValue = null;
                }
            }
            core.Period    = periodValue;
            core.Costs     = costs;
            position.Offer = core;
        }
Example #30
0
        public Offer[] GetOffers(uint client)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Начал загрузку предложений для клиента {0}", client);
            }
            var sql   = String.Format(@"
set @UserId = (select Id
from Customers.Users
where ClientId = ?client
limit 1);

call Customers.GetPrices(@UserId);

delete p from Usersettings.Prices p
	join Usersettings.PricesData pd on pd.PriceCode = p.PriceCode
where pd.IsLocal = 1;

select c0.ProductId, c0.CodeFirmCr, p.RegionCode, p.FirmCode, {0} as Cost, c0.Quantity, c0.Junk, c0.Id as CoreId, c0.Code, c0.CodeCr, c0.PriceCode
from Usersettings.Prices p
	join farm.core0 c0 on c0.PriceCode = p.PriceCode
		join farm.CoreCosts cc on cc.Core_Id = c0.Id and cc.PC_CostCode = p.CostCode
	join Catalogs.Products p on p.Id = c0.ProductId
	join Catalogs.Catalog c on c.Id = p.CatalogId
	join Catalogs.Assortment a on a.CatalogId = c.Id and a.ProducerId = c0.CodeFirmCr
where p.Actual = 1
;", QueryParts.CostSubQuery("c0", "cc", "p"));
            var watch = Stopwatch.StartNew();

            watch.Start();

            var data = Db.Read(sql,
                               r => new Offer(new OfferId(r.GetUInt32("FirmCode"),
                                                          r.GetUInt64("RegionCode")),
                                              r.GetUInt32("ProductId"),
                                              r.GetUInt32("CodeFirmCr"),
                                              r.GetDecimal("Cost"),
                                              r.GetBoolean("Junk"),
                                              SafeConvert.ToUInt32(r["Quantity"].ToString()),
                                              r.GetUInt64("CoreId"),
                                              r.GetString("Code"),
                                              r.GetString("CodeCr"),
                                              r.GetUInt32("PriceCode")),
                               new { client })
                       .ToArray();

            watch.Stop();
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Загрузка предложений для клиента {0} заняла {1}с", client, watch.Elapsed.TotalSeconds);
            }

            return(data);
        }