예제 #1
0
 public static void AddWebServiceLog(DateTime searchDate, string partNumber, string manufacturer, string clientIP, string ClientID)
 {
     using (var dc = new DCFactory<LogDataContext>())
     {
         dc.DataContext.ExecuteCommand(
             "insert into SearchSparePartsWebServiceLog (SearchDate,PartNumber,Manufacturer,ClientIP, ClientID) values ({0},{1},{2},{3},{4})",
             searchDate, partNumber, manufacturer, clientIP, ClientID);
         dc.SetCommit();
     }
 }
예제 #2
0
 public static void AddLog( DateTime searchDate, string partNumber, string clientIP )
 {
     using (var dc = new DCFactory<LogDataContext>())
     {
         dc.DataContext.ExecuteCommand(
             "insert into SearchSparePartsLog (SearchDate,PartNumber,ClientIP) values ({0},{1},{2})",
             searchDate, partNumber, clientIP );
         dc.SetCommit();
     }
 }
        protected void btnSave_Click( object sender, EventArgs e )
        {
            using (var DC = new DCFactory<StoreDataContext>())
            {
                try
                {
                    byte newPrc = Convert.ToByte(txtPrcExcessPriceConfig.Text);
                    DC.DataContext.spUpdUSPrcExcessPrice(SiteContext.Current.User.UserId, newPrc);
                    phSaveOK.Visible = true;

                    DC.SetCommit();
                }
                catch
                {
                    phSaveError.Visible = true;
                }
            }
        }
        protected void _listView_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            var row = e.Item.Controls[1].Controls[0];
            var o = ((DropDownList)row.FindControl("_StatusBoxList")).SelectedValue;
            var oID = ((HtmlInputHidden)row.FindControl("OrderLineID")).Value;

            int i;
            byte StatusID;
            if (int.TryParse(oID, out i) && byte.TryParse(o, out StatusID))
            {
                using (var ctxStore = new DCFactory<StoreDataContext>())
                {

                    OrderLine CurOrderLine = ctxStore.DataContext.OrderLines.Where(x => x.OrderLineID == i).FirstOrDefault();

                    CurOrderLine.ChangeLiteStatus(StatusID);
                    CurOrderLine.CurrentStatusDate = DateTime.Today;
                    ctxStore.DataContext.SubmitChanges();
                    ctxStore.SetCommit();
                        //    var pos = Array.IndexOf(CurrentOrderLines, CurrentOrderLines.Where(x => x.OrderLineID == i).FirstOrDefault() );
                    //CurrentOrderLines[pos].CurrentStatus = StatusID; // Класть сюда весь объект нельзя, так как он будет использоваться после  диспоузинга датаконтекста
                }

            }
        }
        public void SaveStatusChanges()
        {
            var mas = SavedStatuses.Value.Split(';');
            if (mas.Length > 1)
            {
                using (var ctxStore = new DCFactory<StoreDataContext>())
                {
                    foreach (var pair in mas)
                    {
                        var curPair = pair.Split(',');
                        int i;
                        byte StatusID;

                        if (int.TryParse(curPair[0], out i) && byte.TryParse(curPair[1], out StatusID))
                        {
                            OrderLine CurOrderLine = ctxStore.DataContext.OrderLines.Where(x => x.OrderLineID == i).FirstOrDefault();
                            CurOrderLine.ChangeLiteStatus(StatusID);
                            CurOrderLine.CurrentStatusDate = DateTime.Today;
                            ctxStore.DataContext.SubmitChanges();
                            ctxStore.SetCommit();
                        }
                    }
                    CurrentOrderLines = null;
                }
            }
        }
예제 #6
0
        public static string AcceptOnlineAccessOffer(Guid maintUid, string username, string password, Boolean expiredAllow)
        {
            //var maintEntry = GetEntry(maintUid, expiredAllow);
            //if (maintEntry.EntryPurpose != UserMaintEntryPurpose.ActivateClient && maintEntry.EntryPurpose != UserMaintEntryPurpose.ExistingClientWebAccess ||
            //    string.IsNullOrEmpty(maintEntry.ClientID))
            //    throw new BLException("Некорректное состояние регистрационных данных");

            //var regData = maintEntry.RegistrationData;
            //if(regData == null || string.IsNullOrEmpty(regData.Email))
            //    throw new BLException("Некорректное состояние регистрационных данных");

            //if (UserDac.GetUserByClientId(maintEntry.ClientID) != null && !string.IsNullOrEmpty(UserDac.GetUserByClientId(maintEntry.ClientID).Username))
            //    throw new BLException("Учетная запись сайта уже существует для данного клиента");

            var maintEntry = GetEntry(maintUid, expiredAllow);

            if (maintEntry.EntryPurpose != UserMaintEntryPurpose.ExistingClientWebAccess && !maintEntry.UserID.HasValue)
                throw new BLException("Некорректное состояние регистрационных данных");

            var regData = maintEntry.RegistrationDataExt;
            if (regData == null || string.IsNullOrEmpty(regData.Email))
                throw new BLException("Некорректное состояние регистрационных данных");

            if (!string.IsNullOrEmpty(UserDac.GetUserByUserId(maintEntry.UserID.Value).Username))
                throw new BLException("Учетная запись сайта уже существует для данного клиента");

            string clientId = UserDac.GetUserByUserId(maintEntry.UserID.Value).AcctgID;

            using(var mtx = new DCFactory<StoreDataContext>(System.Data.IsolationLevel.ReadCommitted,false, null, true))
            {

                mtx.DataContext.spUpdUsersNamePswd( /*maintEntry.ClientID*/clientId, username, password.GetMD5Hash());
                //UserDac.AddUser(
                //    new User
                //    {
                //        Username = username,
                //        Password = password.GetMD5Hash(),
                //        Role = SecurityRole.Client,
                //        AcctgID = maintEntry.ClientID
                //    },
                //    mtx.DataContext );

                UserMaintDac.DeleteEntry(maintEntry.EntryUid, mtx.DataContext);

                mtx.DataContext.spUpdUserEmail(maintEntry.ClientID, maintEntry.RegistrationData.Email);
                mtx.SetCommit();
            }
            //Здесь возращаем не  maintEntry.ClientId, а clientId, так как он еще не заполнен в UserMaintEntries
            return clientId;
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (var dc = new DCFactory<StoreDataContext>())
            {
                //dc.DataContext.Log = new DebuggerWriter();
                var user = dc.DataContext.Users.Where(x => x.UserID == data.Profile.UserId).FirstOrDefault();
                user.ClientGroup = int.Parse(_clientGroupName.SelectedValue);
                data.Profile.ClientGroup = (RmsAuto.Acctg.ClientGroup)(int.Parse(_clientGroupName.SelectedValue));
                user.IsChanged = true;
                user.IsChecked = chbIsChecked.Checked;
                data.Profile.IsChecked = chbIsChecked.Checked;
                //if (data.Profile.Category == ClientCategory.PhysicalIP)
                //{
                data.Profile.ClientName = txtClientName.Text;//_ClientNameIP.Text;
                //}
               // dc.DataContext.SubmitChanges();

                data.Profile.ContactPersonSurname = _ContactLastName.Text;
                data.Profile.ContactPersonName = _ContactFirstName.Text;
                // _ContactMiddleName.Text = data.Profile.ContactMiddleName;
                data.Profile.ContactPersonPhone = _ContactPhone.Text;
                data.Profile.ContactPersonExtPhone = _ContactExtPhone.Text;
                data.Profile.ContactPersonFax = _ContactFax.Text;
               // data.Profile.ScheduleOfice = _ScheduleOfice.Text;
                //data.Profile.ScheduleStock = _ScheduleStock.Text;
                data.Profile.ShippingAddress = _ShippingAddress.Text;
                data.Profile.ScopeType = _ScopeType.Text;
                data.Profile.DiscountCardNumber = _DiscountCardNumber.Text;
                data.Profile.HowKnow = _HowKnow.Text;
                data.Profile.ContactPosition = _ContactPosition.Text;

                data.Profile.DirectorLastName = _txtDirectorLastName.Text;
                data.Profile.DirectorFirstName = _txtDirectorFirstName.Text;

                //DiscountCardNumber = _discountCardNumber.Value,

                    //INN = (ClientCategory == ClientCategory.PhysicalIP ? _txtINNPIP.Text : _txtINNLegal.Text),
                data.Profile.BankAddress = _txtBankAddress.Text;
                data.Profile.CompanyName = txtClientName.Text;

                data.Profile.BankName = _txtBankName.Text;
                data.Profile.IBAN = _txtIBAN.Text;
                data.Profile.SWIFT = _txtSWIFT.Text;

                data.Profile.DirectorName = _txtDirectorFirstName.Text;
                data.Profile.DirectorSurname = _txtDirectorLastName.Text;

                data.Profile.CorrespondentBankName = _txtCorrespondentBankName.Text;
                data.Profile.CorrespondentIBAN = _txtCorrespondentIBAN.Text;
                data.Profile.CorrespondentSWIFT = _txtCorrespondentSWIFT.Text;
                data.Profile.CorrespondentBankAddress = _txtCorrespondentBankAddrss.Text;

                //using (dcCommonDataContext DC = new dcCommonDataContext())
                //{
                //    var bank = DC.spSelBankInfoByBIC(_txtIBAN.Text).FirstOrDefault();
                //    if (bank != null)
                //    {
                //        bank.BankInfo_Acc = _BankKS.Text;
                //        bank.BankInfo_Name = _BankName.Text;
                //    }
                //    else
                //    {
                //        _BankBIC.Text = "Неверный БИК";
                //    }
                //}

                //data.Profile.BalanceManLastName = _txtBalanceManLastName.Text;
                //data.Profile.BalanceManFirstName = _tctBalanceManFirstName.Text;
                //data.Profile.BalanceManMiddleName = _txtBalanceManMiddleName.Text;
                //data.Profile.BalanceManPhone = _txtBalanceManPhone.Text;
                //data.Profile.BalanceManPosition = _txtBalanceManPosition.Text;
                //data.Profile.BalanceManEmail = _txtBalanceManEmail.Text;
                data.Profile.Email = _Email.Text;
                //data.Profile.DirectorPosition = _txtDirectorPosition.Text;

                dc.DataContext.spUpdUsersLight(data.Profile.AcctgId, data.Profile.ClientName, data.Profile.Email, (byte)data.Profile.TradingVolume, (byte)data.Profile.Category,
                data.Profile.CountryID, data.Profile.RegionID, data.Profile.Locality, data.Profile.ContactPersonSurname, data.Profile.ContactPersonName, "" /*data.Profile.ContactMiddleName*/,
                data.Profile.ContactPersonPhone, data.Profile.ContactPersonExtPhone, data.Profile.ScopeType, data.Profile.HowKnow, data.Profile.ManagerId, "", data.Profile.IsChecked, data.Profile.IsRestricted,
                (int)data.Profile.ClientGroup, data.Profile.PrepaymentPercent, data.Profile.PersonalMarkup, data.Profile.ContactPersonFax, data.Profile.ScheduleOfice, data.Profile.ScheduleStock, data.Profile.ShippingAddress,
                data.Profile.RmsStoreId, data.Profile.DiscountCardNumber, data.Profile.ContactPersonPosition, data.Profile.LegalName, data.Profile.INN, data.Profile.OGRNIP, data.Profile.KPP, data.Profile.OGRN,
                data.Profile.NDSAggent, data.Profile.OficialAddress, data.Profile.RealAddress, data.Profile.Account, data.Profile.BankBIC, data.Profile.BankINN, data.Profile.DirectorPosition,
                data.Profile.DirectorLastName, data.Profile.DirectorFirstName, data.Profile.DirectorMiddleName, data.Profile.BalanceManPosition,
                data.Profile.BalanceManLastName, data.Profile.BalanceManFirstName, data.Profile.BalanceManMiddleName,
                data.Profile.BalanceManPhone, data.Profile.BalanceManEmail, data.Profile.ReclamationPeriod);

                dc.SetCommit();
            }

            //TODO сделать возможность в фабрике управлять connection string: чтобы иметь возможность выставить свойство MultipleActiveResultSet (MARS)
            // для того чтобы сделать оба действия в транзакции см. выше и ниже

            using (var dc = new DCFactory<StoreDataContext>(false))
            {
                string query = @"exec dbo.spLightUpdAutoOrder {0}, {1}";
                dc.DataContext.ExecuteCommand(query, SiteContext.Current.CurrentClient.Profile.UserId, false /* chbIsAutoOrder.Checked */);
            }

            using (var dc = new DCFactory<StoreDataContext>(false))
            {
                string query = @"exec dbo.spLightUpdClientName {0}, {1}";
                dc.DataContext.ExecuteCommand(query, SiteContext.Current.CurrentClient.Profile.UserId, data.Profile.ClientName /* chbIsAutoOrder.Checked */);
            }

            using (var dc = new DCFactory<StoreDataContext>(false))
            {
                string query = @"update dbo.Users set PrepaymentPercent = {0} where UserId = {1}";
                if (dc.DataContext.ExecuteCommand(query, double.Parse(_prepaymentPercentLabel.Text), SiteContext.Current.CurrentClient.Profile.UserId) == 1)
                {
                    data.Profile.PrepaymentPercent =  decimal.Parse(_prepaymentPercentLabel.Text);
                }
            }

            using (var dc = new DCFactory<StoreDataContext>(false))
            {
                string query = @"exec dbo.spLightUpdPaymentDelay {0}, {1}";
                dc.DataContext.ExecuteCommand(query, SiteContext.Current.CurrentClient.Profile.UserId, int.Parse(_DelayDays.Text));
            }

            using (var dc = new DCFactory<StoreDataContext>(false))
            {
                string query = @"exec dbo.spLightUpdPersonalManager {0}, {1}";
                data.Profile.ManagerId = _managerList.SelectedValue;
                dc.DataContext.ExecuteCommand(query, SiteContext.Current.CurrentClient.Profile.UserId, _managerList.SelectedValue);
            }

            using (var dc = new DCFactory<StoreDataContext>(false))
            {
                string query = @"exec dbo.spLightUpdEmail {0}, {1}";
                data.Profile.ManagerId = _managerList.SelectedValue;
                dc.DataContext.ExecuteCommand(query, SiteContext.Current.CurrentClient.Profile.UserId, email2.Text);
            }

            LightBO.UpdateUserLimit(SiteContext.Current.CurrentClient.Profile.UserId, decimal.Parse(_paymentLimit.Text));

            ShowMessage("Data is successfully saved");
        }
예제 #8
0
        protected void _listView_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            var row = e.Item.Controls[1].Controls[0];
            var o = ((DropDownList)row.FindControl("_StatusBoxList")).SelectedValue;
            var oID = ((HyperLink)row.FindControl("_orderLink")).Text.Split(' ')[1].TrimStart('№');

            byte i;
            byte StatusID;
            if (byte.TryParse(oID, out i) && byte.TryParse(o, out StatusID))
            {
                using (var ctxStore = new DCFactory<StoreDataContext>())
                {
                    List<OrderLine> OrderLinesLoaded = ctxStore.DataContext.OrderLines.Where(x => x.OrderID == i).ToList();
                    foreach (OrderLine ordln in OrderLinesLoaded)
                    {
                        ordln.CurrentStatus = StatusID;
                        ordln.CurrentStatusDate = DateTime.Today;
                        ctxStore.DataContext.SubmitChanges();
                        ctxStore.SetCommit();
                    }
                }
            }
        }