public void bntCreate_Click(Object sender, EventArgs e) { var id = Page.Request.Params["id"]; var districtId = Convert.ToInt32(ddlDistrict.SelectedValue); var district = new Districts { ID = districtId }; district.GetById(); var city = new City { Name = tbName.Text, RegionID = Convert.ToInt32(ddlRegion.SelectedValue), TrackID = district.TrackID, DistrictID = districtId, IsMainCity = cbIsMainCity.Checked ? 1 : 0, Distance = Convert.ToInt32(tbDistance.Text), SOATO = tbSOATO.Text, DistanceFromCity = Convert.ToInt32(tbDistanceFromCity.Text) }; if (id == null) { city.Create(); } else { city.ID = Convert.ToInt32(id); city.Update(); } //загружаем города в оперативную память var cityLoad = new City(); Application["CityList"] = cityLoad.GetAllItemsToList(); Page.Response.Redirect("~/ManagerUI/Menu/Souls/CityView.aspx"); }
protected void Page_Load(object sender, EventArgs e) { OtherMethods.ActiveRightMenuStyleChanche("hlSouls", this.Page); OtherMethods.ActiveRightMenuStyleChanche("hlDistricts", this.Page); Page.Title = PagesTitles.ManagerDistrictEdit + BackendHelper.TagToValue("page_title_part"); #region Блок доступа к странице var userInSession = (Users)Session["userinsession"]; var rolesList = Application["RolesList"] as List <Roles>; var currentRole = (Roles)rolesList.SingleOrDefault(u => u.Name.ToLower() == userInSession.Role.ToLower()); if (currentRole.PageDistrictEdit != 1) { Response.Redirect("~/Error.aspx?id=1"); } #endregion if (Page.Request.Params["id"] != null) { var district = new Districts { ID = Convert.ToInt32(Page.Request.Params["id"]) }; district.GetById(); if (!IsPostBack) { tbDeliveryTerms.Text = district.DeliveryTerms.ToString(); tbName.Text = district.Name; var track = new Tracks(); ddlTrack.DataSource = track.GetAllItems(); ddlTrack.DataTextField = "Name"; ddlTrack.DataValueField = "ID"; ddlTrack.DataBind(); ddlTrack.Items.Insert(0, new ListItem("Выберите направление...", "0")); ddlTrack.SelectedValue = district.TrackID.ToString(); if (district.Monday == 1) { cbMonday.Checked = true; } if (district.Tuesday == 1) { cbTuesday.Checked = true; } if (district.Wednesday == 1) { cbWednesday.Checked = true; } if (district.Thursday == 1) { cbThursday.Checked = true; } if (district.Friday == 1) { cbFriday.Checked = true; } if (district.Saturday == 1) { cbSaturday.Checked = true; } if (district.Sunday == 1) { cbSunday.Checked = true; } } } }
protected void ImportXLS_Click(object sender, EventArgs e) { DataSet result = new DataSet(); string message; if (FileUploader.HasFile) { result = ReadXLSMethods.ReadXLS(FileUploader.PostedFile.InputStream); if (result.Tables.Count == 0) { labelStatus.Text = "Неверный тип файла"; return; } var id = Page.Request.Params["id"]; var userInSession = (Users)Session["userinsession"]; string userDiscount; int userID; int rowsCount = 0; int rowsSuccessCount = 0; var user = new Users { ID = UserID, Login = userInSession.Login, Email = userInSession.Email, Name = userInSession.Name, Family = userInSession.Family, Role = userInSession.Role, RussRole = UsersHelper.RoleToRuss(userInSession.Role), IsCourse = userInSession.IsCourse }; userID = user.ID; if (user.Role != Users.Roles.User.ToString()) { userDiscount = "0"; userID = 1; } else { userDiscount = user.Discount.ToString(); } int i = 0; result.Tables[0].Columns.Add(new DataColumn()); result.Tables[0].Columns.Add(new DataColumn()); foreach (DataColumn column in result.Tables[0].Columns) { column.ColumnName = i++.ToString(); } if (result.Tables[0].Columns.Count < 22) { labelStatus.Text = "Недостаточное количество колонок в таблице"; return; } if (result.Tables[0].Rows.Count == 0) { labelStatus.Text = "Пустая таблица"; return; } rowsCount = result.Tables[0].Rows.Count; foreach (DataRow row in result.Tables[0].Rows) { bool norm = true; List <string> errors = new List <string>(); Tickets ticket = new Tickets(); int? profileType = null; /// проверка профиля foreach (DataRow rowProfile in selectProfilesDataSet.Rows) { string selectProfileName = String.IsNullOrEmpty(rowProfile["CompanyName"].ToString()) ? String.Format("{0} {1}", rowProfile["FirstName"], rowProfile["LastName"]) : rowProfile["CompanyName"].ToString(); if (selectProfileName == row.ItemArray[0].ToString()) { ticket.UserProfileID = Convert.ToInt32(rowProfile["ID"].ToString()); ticket.UserID = UsersHelper.GetUserIdByUserProfileId(Convert.ToInt32(ticket.UserProfileID)); profileType = Convert.ToInt32(rowProfile["TypeID"].ToString()); if (profileType == 2) { ticket.PrintNaklInMap = 1; ticket.PrintNakl = 0; } else { ticket.PrintNaklInMap = 0; ticket.PrintNakl = 1; } break; } } if (ticket.UserProfileID == null) { norm = false; errors.Add("неверный профиль"); } /// проверка ID города /// int cityId; if (Int32.TryParse(row.ItemArray[1].ToString(), out cityId) != false) { if (CityHelper.CityIDToCityName(row.ItemArray[1].ToString()) != null) { ticket.CityID = Convert.ToInt32(row.ItemArray[1].ToString()); } else { norm = false; errors.Add("неверный ID города"); } } else { norm = false; errors.Add("неверный ID города"); } /// /// Проверка типа улицы if (RecipientStreetPrefixes.Contains(row.ItemArray[2].ToString())) { ticket.RecipientStreetPrefix = row.ItemArray[2].ToString(); } else { norm = false; errors.Add("неверный префикс улицы"); } /// /// Проверка района if (row.ItemArray[3].ToString() != string.Empty) { ticket.RecipientStreet = row.ItemArray[3].ToString(); } else { norm = false; errors.Add("не введена улица"); } /// /// int houseNumber; if (Int32.TryParse(row.ItemArray[4].ToString(), out houseNumber) == true) { ticket.RecipientStreetNumber = houseNumber.ToString(); } else { norm = false; errors.Add("неверный номер дома"); } /// Заполнение корпуса и квартиры if (row.ItemArray[5].ToString() != string.Empty) { ticket.RecipientKorpus = row.ItemArray[5].ToString(); } if (row.ItemArray[6].ToString() != string.Empty) { ticket.RecipientKvartira = row.ItemArray[6].ToString(); } /// /// Проверка фамилии, имени и отчества if (row.ItemArray[7].ToString().Length < 2 || row.ItemArray[8].ToString().Length < 2 || row.ItemArray[9].ToString().Length < 2) { norm = false; errors.Add("неверные ФИО"); } else { ticket.RecipientFirstName = row.ItemArray[7].ToString(); ticket.RecipientLastName = row.ItemArray[8].ToString(); ticket.RecipientThirdName = row.ItemArray[9].ToString(); } /// /// Проверка номеров телефона string input1 = row.ItemArray[10].ToString(); string input2 = row.ItemArray[11].ToString(); int numMatches1 = 0; foreach (Match m in Regex.Matches(input1, patternPhone)) { numMatches1++; } int numMatches2 = 0; foreach (Match m in Regex.Matches(input2, patternPhone)) { numMatches2++; } if (row.ItemArray[10].ToString() == string.Empty || numMatches1 != 1) { norm = false; errors.Add("неверный 1 номер телефона"); } else { ticket.RecipientPhone = row.ItemArray[10].ToString(); } if (row.ItemArray[11].ToString() != string.Empty && numMatches2 != 1) { norm = false; errors.Add("неверный 2 номер телефона"); } else { if (row.ItemArray[11].ToString() != string.Empty) { ticket.RecipientPhoneTwo = row.ItemArray[11].ToString(); } } /// /// Проверка стоимости доставки для получателя string patternCost = @"^\d+,\d{2}$"; if (row.ItemArray[12].ToString() != string.Empty) { //if (Regex.Matches(row.ItemArray[12].ToString(), patternCost).Count == 1) try { ticket.DeliveryCost = Convert.ToDecimal(row.ItemArray[12].ToString()); } catch { norm = false; errors.Add("неверная стоимость для получателя"); } } else { ticket.DeliveryCost = 0; } /// /// Проверка товаров List <Goods> goods = new List <Goods>(); List <string> goodsStr = row.ItemArray[13].ToString().Split(';').ToList(); if (goodsStr.Count == 0) { norm = false; errors.Add("не введены товары"); } foreach (string goodStr in goodsStr) { List <string> goodParams = goodStr.Split('|').ToList(); if (goodParams.Count != 4) { norm = false; errors.Add("неверно заполнены товары"); goods = new List <Goods>(); break; } string goodDesc = goodParams[0]; string goodModel = goodParams[1]; string goodCost = goodParams[2]; string goodCount = goodParams[3]; /// var titleForCheck = new Titles(); titleForCheck.Name = goodDesc.Trim(); titleForCheck.GetByName(); if (titleForCheck.ID == 0) { norm = false; errors.Add("неверно заполнены товары"); goods = new List <Goods>(); break; } int count; if (Int32.TryParse(goodCount, out count) == false) { norm = false; errors.Add("неверно заполнены товары"); goods = new List <Goods>(); break; } if (Regex.Matches(goodCost, patternCost).Count != 1) { norm = false; errors.Add("неверно заполнены товары"); goods = new List <Goods>(); break; } Goods good = new Goods() { Description = OtherMethods.BeInUseReplace(goodDesc).Trim(), Model = goodModel.Trim(), Number = Convert.ToInt32(goodCount), Cost = Convert.ToDecimal(goodCost) }; goods.Add(good); } /// /// Получение стоимости за товары ticket.AssessedCost = 0; foreach (Goods good in goods) { ticket.AssessedCost += good.Number * good.Cost; } /// /// Проверка количества грузовых мест int boxesNumber; if (row.ItemArray[14].ToString() != string.Empty) { if (Int32.TryParse(row.ItemArray[14].ToString(), out boxesNumber) != false) { ticket.BoxesNumber = boxesNumber; } else { norm = false; errors.Add("неверно введено количество коробок"); } } else { ticket.BoxesNumber = 1; } /// /// Проверка даты отправки //if (Regex.Matches(row.ItemArray[15].ToString(), patternDate).Count == 1) //{ DateTime date1; try { date1 = Convert.ToDateTime(Convert.ToDateTime(row.ItemArray[15].ToString()).ToString("dd-MM-yyyy")); DateTime date2 = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("dd-MM-yyyy")); if (ticket.CityID != null) { var allCity = Application["CityList"] as List <City>; var city = allCity.First(u => u.ID == Convert.ToInt32(ticket.CityID)); var district = new Districts { ID = Convert.ToInt32(city.DistrictID) }; district.GetById(); var selectDayOfWeek = Convert.ToDateTime(Convert.ToDateTime(row.ItemArray[15].ToString()).ToString("dd-MM-yyyy")).DayOfWeek; if ((selectDayOfWeek == DayOfWeek.Monday && district.Monday != 1) || (selectDayOfWeek == DayOfWeek.Tuesday && district.Tuesday != 1) || (selectDayOfWeek == DayOfWeek.Wednesday && district.Wednesday != 1) || (selectDayOfWeek == DayOfWeek.Thursday && district.Thursday != 1) || (selectDayOfWeek == DayOfWeek.Friday && district.Friday != 1) || (selectDayOfWeek == DayOfWeek.Saturday && district.Saturday != 1) || (selectDayOfWeek == DayOfWeek.Sunday && district.Sunday != 1)) { norm = false; errors.Add("отправка возможна только в дни отправки"); } if (date1 < date2 && ticket.CityID != 11) { norm = false; errors.Add("отправка в города отличные от Минска возможна только на следующий день после создания заявки!"); } if (date1 < Convert.ToDateTime(DateTime.Now.ToString("dd-MM-yyyy")) && ticket.CityID == 11) { norm = false; errors.Add("доставка по Минску возможна только с текущего дня и далее!"); } ticket.DeliveryDate = date1; } } catch (Exception) { norm = false; errors.Add("неверная дата"); } //} //else //{ //norm = false; //errors.Add("неверный формат даты отправки"); //} /// /// Комментарии if (row.ItemArray[16].ToString() != string.Empty) { ticket.Note = row.ItemArray[16].ToString(); } /// /// Проверка данных документов if (profileType == 2 || profileType == 3) { if (Regex.Matches(row.ItemArray[17].ToString(), patternTTNSeria).Count == 1) { ticket.TtnSeria = row.ItemArray[17].ToString(); } else { norm = false; errors.Add("неверно введена ТТН серия"); } if (Regex.Matches(row.ItemArray[18].ToString(), patternTTNNumber).Count == 1) { ticket.TtnNumber = row.ItemArray[18].ToString(); } else { norm = false; errors.Add("неверно введен ТТН номер"); } } else { ticket.TtnNumber = string.Empty; ticket.TtnSeria = string.Empty; } ticket.OtherDocuments = row.ItemArray[19].ToString(); /// /// Проверка серии и номера паспорта if (Regex.Matches(row.ItemArray[20].ToString(), patternTTNSeria).Count == 1) { ticket.PassportSeria = row.ItemArray[20].ToString(); } else { norm = false; errors.Add("неверно введена серия паспорта"); } if (Regex.Matches(row.ItemArray[21].ToString(), patternTTNNumber).Count == 1) { ticket.PassportNumber = row.ItemArray[21].ToString(); } else { norm = false; errors.Add("неверно введен номер паспорта"); } /// /// Подсчет стоимости за услугу List <GoodsFromAPI> goodsAPI = new List <GoodsFromAPI>(); foreach (Goods good in goods) { GoodsFromAPI goodAPI = new GoodsFromAPI() { Description = good.Description, Number = good.Number }; goodsAPI.Add(goodAPI); } if (goodsAPI.Count > 0) { var gruzobozCost = Calculator.Calculate(goodsAPI, Convert.ToInt32(ticket.CityID), userID, Convert.ToInt32(ticket.UserProfileID), profileType.ToString(), ticket.AssessedCost.ToString(), Convert.ToInt32(userDiscount)); //если стоимость за услугу не конвертируется в decimal - значит записываем 0 try { ticket.GruzobozCost = Decimal.Parse(gruzobozCost); } catch (Exception) { ticket.GruzobozCost = 0; } /// /// Расчет веса ticket.Weight = GoodsHelper.GoodsWeight(goodsAPI); } /// /// Заполнение полей склада if (warehouses.Rows.Count == 0) { norm = false; errors.Add("ошибка склада"); } DataRow rowWareHouses = warehouses.Rows[0]; ticket.SenderApartmentNumber = rowWareHouses["ApartmentNumber"].ToString(); ticket.SenderCityID = Convert.ToInt32(rowWareHouses["CityID"].ToString()); ticket.SenderHousing = rowWareHouses["Housing"].ToString(); ticket.SenderStreetName = rowWareHouses["StreetName"].ToString(); ticket.SenderStreetNumber = rowWareHouses["StreetNumber"].ToString(); ticket.SenderStreetPrefix = rowWareHouses["StreetPrefix"].ToString(); /// /// СОЗДАНИЕ ЗАЯВКИ /// string error = string.Empty; foreach (string errorMsg in errors) { error += errorMsg; error += ", "; } rowsError.Add(error); string color; if (errors.Count != 0) { color = "redRow"; } else { color = "greenRow"; } rowsColor.Add(color); if (norm == true) { if (id == null) { rowsSuccessCount++; //записываем хеши для заявки if (user.Role != Users.Roles.User.ToString()) { ticket.SecureID = OtherMethods.CreateUniqId("1" + DateTime.Now.ToString("yyMdHms")); ticket.FullSecureID = OtherMethods.CreateFullUniqId("1" + DateTime.Now.ToString("yyMdHms")); } else { ticket.SecureID = OtherMethods.CreateUniqId(user.ID + DateTime.Now.ToString("yyMdHms")); ticket.FullSecureID = OtherMethods.CreateFullUniqId(user.ID + DateTime.Now.ToString("yyMdHms")); } for (int j = 0; j < goods.Count; j++) //сохраняем заявки { goods[j].TicketFullSecureID = ticket.FullSecureID; goods[j].Create(); } ticket.Create(); #region Отправка емейла логистам var logistRb = BackendHelper.TagToValue("logist_rb_email"); var logistMinsk = BackendHelper.TagToValue("logist_minsk_email"); var isMinskRegion = BackendHelper.TagToValue("logist_minsk_region"); var senderCity = new City { ID = Convert.ToInt32(ticket.SenderCityID) }; senderCity.GetById(); if (isMinskRegion != "true") { if (!string.IsNullOrEmpty(logistRb) && senderCity.DistrictID != 10) { try { EmailMethods.MailSend("Создана новая заявка с забором в РБ", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistRb, true); } catch (Exception) { // ignored } } else { if (!string.IsNullOrEmpty(logistMinsk) && !(ticket.SenderCityID == 11 && ticket.SenderStreetName.ToLower() == BackendHelper.TagToValue("loading_point_street").ToLower() && ticket.SenderStreetNumber == BackendHelper.TagToValue("loading_point_street_number"))) { try { EmailMethods.MailSend("Создана новая заявка с забором в Минске и районе", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistMinsk, true); } catch (Exception) { // ignored } } } } else { if (!string.IsNullOrEmpty(logistRb) && senderCity.RegionID != 1) { try { EmailMethods.MailSend("Создана новая заявка с забором в РБ", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistRb, true); } catch (Exception) { // ignored } } else { if (!string.IsNullOrEmpty(logistMinsk) && !(ticket.SenderCityID == 11 && ticket.SenderStreetName.ToLower() == BackendHelper.TagToValue("loading_point_street") && ticket.SenderStreetNumber == BackendHelper.TagToValue("loading_point_street_number"))) { try { EmailMethods.MailSend("Создана новая заявка с забором в Минске и области", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistMinsk, true); } catch (Exception) { // ignored } } } } #endregion } } } for (int j = 0; j < result.Tables[0].Rows.Count; j++) { result.Tables[0].Rows[j][22] = rowsError[j]; result.Tables[0].Rows[j][23] = rowsColor[j]; } labelStatus.Text = "Успешно импортировано " + rowsSuccessCount.ToString() + " из " + rowsCount.ToString() + " заявок"; ListXML.DataSource = result.Tables[0]; ListXML.DataBind(); } }
public List <TicketsCreateResult> CreateTickets(List <TicketToCreate> tickets, int id) { List <TicketsCreateResult> result = new List <TicketsCreateResult>(); selectProfilesDataSet = dm.QueryWithReturnDataSet(string.Format("SELECT * FROM `usersprofiles` WHERE `UserID` = {0} AND `StatusID` = 1", id)).Tables[0]; //////////////// string userDiscount; int userID; int rowsCount = 0; int rowsSuccessCount = 0; var user = new Users { ID = id }; user.GetById(); userID = user.ID; if (user.Role != Users.Roles.User.ToString()) { userDiscount = "0"; userID = 1; } else { userDiscount = user.Discount.ToString(); } int num = 0; foreach (TicketToCreate row in tickets) { bool norm = true; List <string> errors = new List <string>(); Tickets ticket = new Tickets(); int? profileType = null; TicketsCreateResult resultTicket = new TicketsCreateResult(); resultTicket.number = num.ToString(); num++; /// проверка профиля foreach (DataRow rowProfile in selectProfilesDataSet.Rows) { string selectProfileName = String.IsNullOrEmpty(rowProfile["CompanyName"].ToString()) ? String.Format("{0} {1}", rowProfile["FirstName"], rowProfile["LastName"]) : rowProfile["CompanyName"].ToString(); if (selectProfileName == row.ProfileName) { ticket.UserProfileID = Convert.ToInt32(rowProfile["ID"].ToString()); ticket.UserID = UsersHelper.GetUserIdByUserProfileId(Convert.ToInt32(ticket.UserProfileID)); profileType = Convert.ToInt32(rowProfile["TypeID"].ToString()); if (profileType == 2) { ticket.PrintNaklInMap = 1; ticket.PrintNakl = 0; } else { ticket.PrintNaklInMap = 0; ticket.PrintNakl = 1; } break; } } if (ticket.UserProfileID == null) { norm = false; errors.Add("неверный профиль"); } /// проверка ID города /// int cityId; if (Int32.TryParse(row.CityID, out cityId) != false) { if (CityHelper.CityIDToCityName(row.CityID.ToString()) != null) { ticket.CityID = Convert.ToInt32(row.CityID.ToString()); } else { norm = false; errors.Add("неверный ID города"); } } else { norm = false; errors.Add("неверный ID города"); } /// /// Проверка типа улицы if (row.StreetPrefix == null || RecipientStreetPrefixes.Contains(row.StreetPrefix)) { ticket.RecipientStreetPrefix = row.StreetPrefix; } else { norm = false; errors.Add("неверный префикс улицы"); } /// /// Проверка района if (row.StreetName != string.Empty) { ticket.RecipientStreet = row.StreetName; } else { norm = false; errors.Add("не введена улица"); } /// /// int houseNumber; if (Int32.TryParse(row.HouseNumber, out houseNumber)) { ticket.RecipientStreetNumber = houseNumber.ToString(); } else { norm = false; errors.Add("неверный номер дома"); } /// Заполнение корпуса и квартиры if (row.Korpus != string.Empty) { ticket.RecipientKorpus = row.Korpus; } if (row.Kvartira != string.Empty) { ticket.RecipientKvartira = row.Kvartira; } /// /// Проверка фамилии, имени и отчества if (row.FirstName == null || row.SecondName == null || row.ThirdName == null || row.FirstName.Length < 2 || row.SecondName.Length < 2 || row.ThirdName.Length < 2) { norm = false; errors.Add("неверные ФИО"); } else { ticket.RecipientFirstName = row.FirstName; ticket.RecipientLastName = row.SecondName; ticket.RecipientThirdName = row.ThirdName; } /// /// Проверка номеров телефона string input1 = row.FirstTelefonNumber; string input2 = row.SecondTelefonNumber; int numMatches1 = 0; if (input1 != null) { foreach (Match m in Regex.Matches(input1, patternPhone)) { numMatches1++; } } int numMatches2 = 0; if (input2 != null) { foreach (Match m in Regex.Matches(input2, patternPhone)) { numMatches2++; } } if (row.FirstTelefonNumber == string.Empty || numMatches1 != 1) { norm = false; errors.Add("неверный 1 номер телефона"); } else { ticket.RecipientPhone = row.FirstTelefonNumber; } if (row.SecondTelefonNumber != string.Empty && numMatches2 != 1) { norm = false; errors.Add("неверный 2 номер телефона"); } else { if (row.SecondTelefonNumber != string.Empty) { ticket.RecipientPhoneTwo = row.SecondTelefonNumber; } } /// /// Проверка стоимости доставки для получателя string patternCost = @"^\d+,\d{2}$"; if (row.RecieverCost != string.Empty) { //if (Regex.Matches(row.ItemArray[12].ToString(), patternCost).Count == 1) try { ticket.DeliveryCost = Convert.ToDecimal(row.RecieverCost); } catch { norm = false; errors.Add("неверная стоимость для получателя"); } } else { ticket.DeliveryCost = 0; } /// /// Проверка товаров List <Goods> goods = new List <Goods>(); if (row.Goods == null || row.Goods.Count == 0) { norm = false; errors.Add("не введены товары"); } else { foreach (TicketGood good in row.Goods) { if (string.IsNullOrEmpty(good.GoodName) || string.IsNullOrEmpty(good.GoodModel) || string.IsNullOrEmpty(good.GoodCount) || string.IsNullOrEmpty(good.GoodCost)) { norm = false; errors.Add("неверно заполнены товары"); goods = new List <Goods>(); break; } string goodDesc = good.GoodName; string goodModel = good.GoodModel; string goodCost = good.GoodCost; string goodCount = good.GoodCount; /// var titleForCheck = new Titles(); titleForCheck.Name = goodDesc.Trim(); titleForCheck.GetByName(); if (titleForCheck.ID == 0) { norm = false; errors.Add("неверно заполнены товары: товар не найден"); goods = new List <Goods>(); break; } int count; if (Int32.TryParse(goodCount, out count) == false) { norm = false; errors.Add("неверно заполнены товары: не верное количество"); goods = new List <Goods>(); break; } if (Regex.Matches(goodCost, patternCost).Count != 1) { norm = false; errors.Add("неверно заполнены товары: не верная цена"); goods = new List <Goods>(); break; } Goods goodCreate = new Goods() { Description = OtherMethods.BeInUseReplace(goodDesc).Trim(), Model = goodModel.Trim(), Number = Convert.ToInt32(goodCount), Cost = Convert.ToDecimal(goodCost) }; goods.Add(goodCreate); } /// /// Получение стоимости за товары ticket.AssessedCost = 0; foreach (Goods good in goods) { ticket.AssessedCost += good.Number * good.Cost; } /// /// Проверка количества грузовых мест int boxesNumber; if (row.BoxCount != string.Empty) { if (Int32.TryParse(row.BoxCount, out boxesNumber) != false) { ticket.BoxesNumber = boxesNumber; } else { norm = false; errors.Add("неверно введено количество коробок"); } } else { ticket.BoxesNumber = 1; } } /// /// Проверка даты отправки //if (Regex.Matches(row.ItemArray[15].ToString(), patternDate).Count == 1) //{ DateTime date1; try { date1 = Convert.ToDateTime(Convert.ToDateTime(row.SendDate).ToString("dd-MM-yyyy")); DateTime date2 = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("dd-MM-yyyy")); if (ticket.CityID != null) { var city = new City() { ID = Convert.ToInt32(row.CityID) }; city.GetById(); //var city = allCity.First(u => u.ID == Convert.ToInt32(ticket.CityID)); var district = new Districts { ID = Convert.ToInt32(city.DistrictID) }; district.GetById(); var selectDayOfWeek = Convert.ToDateTime(Convert.ToDateTime(row.SendDate).ToString("dd-MM-yyyy")).DayOfWeek; if ((selectDayOfWeek == DayOfWeek.Monday && district.Monday != 1) || (selectDayOfWeek == DayOfWeek.Tuesday && district.Tuesday != 1) || (selectDayOfWeek == DayOfWeek.Wednesday && district.Wednesday != 1) || (selectDayOfWeek == DayOfWeek.Thursday && district.Thursday != 1) || (selectDayOfWeek == DayOfWeek.Friday && district.Friday != 1) || (selectDayOfWeek == DayOfWeek.Saturday && district.Saturday != 1) || (selectDayOfWeek == DayOfWeek.Sunday && district.Sunday != 1)) { norm = false; errors.Add("отправка возможна только в дни отправки"); } if (date1 < date2 && ticket.CityID != 11) { norm = false; errors.Add("отправка в города отличные от Минска возможна только на следующий день после создания заявки!"); } if (date1 < Convert.ToDateTime(DateTime.Now.ToString("dd-MM-yyyy")) && ticket.CityID == 11) { norm = false; errors.Add("доставка по Минску возможна только с текущего дня и далее!"); } ticket.DeliveryDate = date1; } } catch (Exception) { norm = false; errors.Add("неверная дата"); } //} //else //{ //norm = false; //errors.Add("неверный формат даты отправки"); //} /// /// Комментарии if (row.Comments != string.Empty) { ticket.Note = row.Comments; } /// /// Проверка данных документов if (profileType == 2 || profileType == 3) { if (Regex.Matches(row.TTNSeria, patternTTNSeria).Count == 1) { ticket.TtnSeria = row.TTNSeria; } else { norm = false; errors.Add("неверно введена ТТН серия"); } if (Regex.Matches(row.TTNNmber, patternTTNNumber).Count == 1) { ticket.TtnNumber = row.TTNNmber; } else { norm = false; errors.Add("неверно введен ТТН номер"); } } else { ticket.TtnNumber = string.Empty; ticket.TtnSeria = string.Empty; } ticket.OtherDocuments = row.OtherDocuments; /// /// Проверка серии и номера паспорта if (!string.IsNullOrEmpty(ticket.PassportNumber) || !string.IsNullOrEmpty(ticket.PassportSeria)) { if (Regex.Matches(row.PassportSeria, patternTTNSeria).Count == 1) { ticket.PassportSeria = row.PassportSeria; } else { norm = false; errors.Add("неверно введена серия паспорта"); } if (Regex.Matches(row.PassportNumber, patternTTNNumber).Count == 1) { ticket.PassportNumber = row.PassportNumber; } else { norm = false; errors.Add("неверно введен номер паспорта"); } } /// /// Подсчет стоимости за услугу List <GoodsFromAPI> goodsAPI = new List <GoodsFromAPI>(); foreach (Goods good in goods) { GoodsFromAPI goodAPI = new GoodsFromAPI() { Description = good.Description, Number = good.Number }; goodsAPI.Add(goodAPI); } if (goodsAPI.Count > 0) { var gruzobozCost = Calculator.Calculate(goodsAPI, Convert.ToInt32(ticket.CityID), userID, Convert.ToInt32(ticket.UserProfileID), profileType.ToString(), ticket.AssessedCost.ToString(), Convert.ToInt32(userDiscount)); //если стоимость за услугу не конвертируется в decimal - значит записываем 0 try { ticket.GruzobozCost = Decimal.Parse(gruzobozCost); } catch (Exception) { ticket.GruzobozCost = 0; } /// /// Расчет веса ticket.Weight = GoodsHelper.GoodsWeight(goodsAPI); } /// /// Заполнение полей склада if (warehouses.Rows.Count == 0) { norm = false; errors.Add("ошибка склада"); } DataRow rowWareHouses = warehouses.Rows[0]; if (ticket.SenderCityID != null || !string.IsNullOrEmpty(ticket.SenderHousing) || !string.IsNullOrEmpty(ticket.SenderStreetName) || !string.IsNullOrEmpty(ticket.SenderStreetNumber) || !string.IsNullOrEmpty(ticket.SenderStreetPrefix) || !string.IsNullOrEmpty(ticket.SenderApartmentNumber)) { ticket.SenderApartmentNumber = rowWareHouses["ApartmentNumber"].ToString(); ticket.SenderCityID = Convert.ToInt32(rowWareHouses["CityID"].ToString()); ticket.SenderHousing = rowWareHouses["Housing"].ToString(); ticket.SenderStreetName = rowWareHouses["StreetName"].ToString(); ticket.SenderStreetNumber = rowWareHouses["StreetNumber"].ToString(); ticket.SenderStreetPrefix = rowWareHouses["StreetPrefix"].ToString(); } else { if (Int32.TryParse(row.SenderCityID, out cityId) != false) { if (CityHelper.CityIDToCityName(row.SenderCityID.ToString()) != null) { ticket.SenderCityID = Convert.ToInt32(row.SenderCityID.ToString()); } else { norm = false; errors.Add("неверный ID города отправки"); } } else { norm = false; errors.Add("неверный ID города"); } /// /// Проверка типа улицы if (RecipientStreetPrefixes.Contains(row.SenderStreetPrefix)) { ticket.SenderStreetPrefix = row.SenderStreetPrefix; } else { norm = false; errors.Add("неверный префикс улицы отправки"); } /// /// Проверка района if (row.SenderStreetName != string.Empty) { ticket.SenderStreetName = row.SenderStreetName; } else { norm = false; errors.Add("не введена улица отправки"); } /// /// if (Int32.TryParse(row.SenderHouseNumber, out houseNumber)) { ticket.SenderStreetNumber = houseNumber.ToString(); } else { norm = false; errors.Add("неверный номер дома отправки"); } /// Заполнение корпуса и квартиры if (row.SenderKorpus != string.Empty) { ticket.SenderHousing = row.SenderKorpus; } if (row.Kvartira != string.Empty) { ticket.SenderApartmentNumber = row.SenderKvartira; } } /// /// СОЗДАНИЕ ЗАЯВКИ /// string error = string.Empty; foreach (string errorMsg in errors) { error += errorMsg; error += ", "; } rowsError.Add(error); if (norm == true) { try { rowsSuccessCount++; //записываем хеши для заявки if (user.Role != Users.Roles.User.ToString()) { ticket.SecureID = OtherMethods.CreateUniqId("1" + DateTime.Now.ToString("yyMdHms") + tickets.IndexOf(row)); ticket.FullSecureID = OtherMethods.CreateFullUniqId("1" + DateTime.Now.ToString("yyMdHms") + tickets.IndexOf(row)); } else { ticket.SecureID = OtherMethods.CreateUniqId(user.ID + DateTime.Now.ToString("yyMdHms") + tickets.IndexOf(row)); ticket.FullSecureID = OtherMethods.CreateFullUniqId(user.ID + DateTime.Now.ToString("yyMdHms") + tickets.IndexOf(row)); } resultTicket.ID = ticket.SecureID; for (int j = 0; j < goods.Count; j++) //сохраняем заявки { goods[j].TicketFullSecureID = ticket.FullSecureID; goods[j].Create(); } ticket.Create(); #region Отправка емейла логистам var logistRb = BackendHelper.TagToValue("logist_rb_email"); var logistMinsk = BackendHelper.TagToValue("logist_minsk_email"); var isMinskRegion = BackendHelper.TagToValue("logist_minsk_region"); var senderCity = new City { ID = Convert.ToInt32(ticket.SenderCityID) }; senderCity.GetById(); if (isMinskRegion != "true") { if (!string.IsNullOrEmpty(logistRb) && senderCity.DistrictID != 10) { try { EmailMethods.MailSend("Создана новая заявка с забором в РБ", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistRb, true); } catch (Exception) { // ignored } } else { if (!string.IsNullOrEmpty(logistMinsk) && !(ticket.SenderCityID == 11 && ticket.SenderStreetName.ToLower() == BackendHelper.TagToValue("loading_point_street").ToLower() && ticket.SenderStreetNumber == BackendHelper.TagToValue("loading_point_street_number"))) { try { EmailMethods.MailSend("Создана новая заявка с забором в Минске и районе", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistMinsk, true); } catch (Exception) { // ignored } } } } else { if (!string.IsNullOrEmpty(logistRb) && senderCity.RegionID != 1) { try { EmailMethods.MailSend("Создана новая заявка с забором в РБ", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistRb, true); } catch (Exception) { // ignored } } else { if (!string.IsNullOrEmpty(logistMinsk) && !(ticket.SenderCityID == 11 && ticket.SenderStreetName.ToLower() == BackendHelper.TagToValue("loading_point_street") && ticket.SenderStreetNumber == BackendHelper.TagToValue("loading_point_street_number"))) { try { EmailMethods.MailSend("Создана новая заявка с забором в Минске и области", String.Format("Заявка #{0}, {1}", ticket.SecureID, senderCity.Name), logistMinsk, true); } catch (Exception) { // ignored } } } } #endregion resultTicket.desc = "Заявка создана"; } catch (Exception ex) { resultTicket.desc = "Заявка не создана"; } } else { resultTicket.desc = error; } result.Add(resultTicket); } //////////////// return(result); }
protected void Page_Load(object sender, EventArgs e) { Page.Title = PagesTitles.ManagerUserTicketEditTitle + BackendHelper.TagToValue("page_title_part"); OtherMethods.ActiveRightMenuStyleChanche("hlTickets", this.Page); Form.DefaultButton = btnCreate.UniqueID; AppKey = Globals.Settings.AppServiceSecureKey; FirstUserApiKey = Globals.Settings.FirstUserApiKey; #region Блок доступа к странице var userInSession = (Users)Session["userinsession"]; var rolesList = Application["RolesList"] as List <Roles>; var currentRole = Role = (Roles)rolesList.SingleOrDefault(u => u.Name.ToLower() == userInSession.Role.ToLower()); if (currentRole.PageUserTicketEdit != 1) { Response.Redirect("~/Error.aspx?id=1"); } #endregion #region Блок доступа к данным на странице IsVisibleUserProfileData = true; IsVisibleUserAccountData = true; if (currentRole.PageUserProfileView == 0) { IsVisibleUserProfileData = false; } if (currentRole.PageClientsView == 0) { IsVisibleUserAccountData = false; } trUserProfileData.Visible = IsVisibleUserProfileData; trUserAccountData.Visible = IsVisibleUserAccountData; #endregion #region едирект на страницу всех заявок если заявки нет if (Page.Request.Params["id"] == null || Page.Request.Params["id"] == String.Empty) { Page.Response.Redirect("~/ManagerUI/Menu/Tickets/UserTicketView.aspx"); } #endregion if (!IsPostBack) { #region Загрузка tickets по SecureID или FullSecureID. Метод на очистку. DAL.DataBaseObjects.Tickets ticket; if (Page.Request.Params["id"].Length > 7) { ticket = new DAL.DataBaseObjects.Tickets { FullSecureID = Page.Request.Params["id"] }; ticket.GetByFullSecureId(); } else { ticket = new DAL.DataBaseObjects.Tickets { SecureID = Page.Request.Params["id"] }; ticket.GetBySecureId(); } #endregion #region Создание форм для груза GoodsCount = GoodsHelper.GoodsCount(ticket.FullSecureID); hfHowManyControls.Value = GoodsCount.ToString(); AddGodsInPanel(GoodsCount); #endregion #region Заполнение созданных формы var goods = new Goods { TicketFullSecureID = ticket.FullSecureID }; var ds = goods.GetAllItems("ID", "ASC", "TicketFullSecureID"); var goodsIterator = 1; foreach (DataRow row in ds.Tables[0].Rows) { var tbGoodsDescription = (TextBox)pnlBooks.FindControl("tbGoodsDescription" + goodsIterator); var tbGoodsModel = (TextBox)pnlBooks.FindControl("tbGoodsModel" + goodsIterator); var tbGoodsNumber = (TextBox)pnlBooks.FindControl("tbGoodsNumber" + goodsIterator); var tbGoodsCost = (TextBox)pnlBooks.FindControl("tbGoodsCost" + goodsIterator); var hfGoodsID = (HiddenField)pnlBooks.FindControl("hfGoodsID" + goodsIterator); var hfWithoutAkciza = (HiddenField)pnlBooks.FindControl("hfWithoutAkciza" + goodsIterator); var hfGoodsNumber = (HiddenField)pnlBooks.FindControl("hfGoodsNumber" + goodsIterator); var hfGoodsCost = (HiddenField)pnlBooks.FindControl("hfGoodsCost" + goodsIterator); var hfGoodsDescription = (HiddenField)pnlBooks.FindControl("hfGoodsDescription" + goodsIterator); var hfGoodsModel = (HiddenField)pnlBooks.FindControl("hfGoodsModel" + goodsIterator); tbGoodsDescription.Text = hfGoodsDescription.Value = row["Description"].ToString(); tbGoodsModel.Text = hfGoodsModel.Value = row["Model"].ToString(); tbGoodsNumber.Text = hfGoodsNumber.Value = row["Number"].ToString(); tbGoodsCost.Text = hfGoodsCost.Value = MoneyMethods.MoneySeparator(row["Cost"].ToString()); hfGoodsID.Value = row["ID"].ToString(); hfWithoutAkciza.Value = row["WithoutAkciza"].ToString(); goodsIterator++; } #endregion #region Вывод старых грузов. Метод на очистку. if (GoodsCount == 0) { lblOldGoods.Visible = true; lblOldGoods.Text = "<b>" + OtherMethods.GoodsStringFromTicketID(ticket.ID.ToString()) + "</b><br/>"; } #endregion #region Инициализация сущностей var user = new Users(); user.ID = Convert.ToInt32(ticket.UserID); user.GetById(); #region Блок конфигурации удаления заявки if (currentRole.ActionUserTicketDelete != 1) { btnDelete.Visible = false; } #endregion var profile = new UsersProfiles(); profile.ID = Convert.ToInt32(ticket.UserProfileID); profile.GetById(); #endregion #region блок общей информации SpecialClient = user.SpecialClient; hfID.Value = ticket.ID.ToString(); hfDriverID.Value = ticket.DriverID.ToString(); hfStatusID.Value = ticket.StatusID.ToString(); hfStatusIDOld.Value = ticket.StatusIDOld.ToString(); hfStatusDescription.Value = ticket.StatusDescription; hfAdmissionDate.Value = ticket.AdmissionDate.ToString(); hfUserID.Value = UserID = ticket.UserID.ToString(); hfUserDiscount.Value = user.Discount.ToString(); hfUserProfileType.Value = profile.TypeID.ToString(); hfFullSecureID.Value = ticket.FullSecureID; lblID.Text = ticket.SecureID; hlUser.Text = user.Family + ' ' + user.Name; hlUser.NavigateUrl = "~/ManagerUI/Menu/Souls/ClientEdit.aspx?id=" + ticket.UserID; hlProfile.Text = profile.TypeID == 1 ? (profile.FirstName + ' ' + profile.LastName) : profile.CompanyName; hlProfile.NavigateUrl = "~/ManagerUI/Menu/Souls/ProfileView.aspx?id=" + ticket.UserProfileID; lblProfileType.Text = UsersProfilesHelper.UserProfileTypeToText(Convert.ToInt32(profile.TypeID)); lblCreateDate.Text = OtherMethods.DateConvert(ticket.CreateDate.ToString()); lblAdmissionDate.Text = OtherMethods.DateConvert(ticket.AdmissionDate.ToString()); lblDeliveryDateStatic.Text = OtherMethods.DateConvert(ticket.DeliveryDate.ToString()); lblIsExchange.Text = ticket.IsExchange == 0 ? "нет" : "да"; cbWithoutMoney.Checked = ticket.WithoutMoney != 0; lblNN.Text = ticket.PrintNaklInMap == 0 ? "нет" : "да"; lblPN.Text = ticket.PrintNakl == 0 ? "нет" : "да"; if (String.IsNullOrEmpty(ticket.Comment)) { tdComment.Visible = false; } else { lblComment.Text = WebUtility.HtmlDecode(ticket.Comment); } var regionText = CityHelper.CityToTrack(Convert.ToInt32(ticket.CityID), ticket.ID.ToString()); if (ticket.TrackIDUser != 0 || regionText == "Не задано") { ddlUserTrack.Visible = true; lblTrack.Visible = false; var region = new Tracks(); ddlUserTrack.DataSource = region.GetAllItems(); ddlUserTrack.DataTextField = "Name"; ddlUserTrack.DataValueField = "ID"; ddlUserTrack.DataBind(); ddlUserTrack.Items.Insert(0, new ListItem("Не задано", "0")); ddlUserTrack.SelectedValue = Convert.ToString(ticket.TrackIDUser); } else { lblTrack.Text = regionText; } if (string.IsNullOrEmpty(lblAdmissionDate.Text)) { lblAdmissionDate.Text = "Груз пока не на складе"; } #endregion #region блок информации, заполняемой пользователем AssessedCost = MoneyMethods.MoneySeparator(ticket.AssessedCost.ToString()); hfAssessedCost.Value = ticket.AssessedCost.ToString(); lblAssessedCost.Text = MoneyMethods.MoneySeparator(ticket.AssessedCost.ToString()); tbDeliveryCost.Text = MoneyMethods.MoneySeparator(ticket.DeliveryCost.ToString()); ddlRecipientStreetPrefix.SelectedValue = ticket.RecipientStreetPrefix; tbRecipientStreet.Text = ticket.RecipientStreet; tbRecipientStreetNumber.Text = ticket.RecipientStreetNumber; tbRecipientKorpus.Text = ticket.RecipientKorpus; tbRecipientKvartira.Text = ticket.RecipientKvartira; tbRecipientPhone.Text = ticket.RecipientPhone; tbRecipientPhone2.Text = ticket.RecipientPhoneTwo; ddlSenderStreetPrefix.SelectedValue = ticket.SenderStreetPrefix; tbSenderStreetName.Text = ticket.SenderStreetName; tbSenderStreetNumber.Text = ticket.SenderStreetNumber; tbSenderHousing.Text = ticket.SenderHousing; tbSenderApartmentNumber.Text = ticket.SenderApartmentNumber; tbNote.Text = ticket.Note; tbBoxesNumber.Text = string.IsNullOrEmpty(ticket.BoxesNumber.ToString()) ? "1" : ticket.BoxesNumber.ToString(); tbDeliveryDate.Text = Convert.ToDateTime(ticket.DeliveryDate).ToString("dd-MM-yyyy"); tbRecipientFirstName.Text = ticket.RecipientFirstName; tbRecipientLastName.Text = ticket.RecipientLastName; tbRecipientThirdName.Text = ticket.RecipientThirdName; tbTtnSeria.Text = ticket.TtnSeria; tbTtnNumber.Text = ticket.TtnNumber; tbOtherDocuments.Text = ticket.OtherDocuments; tbPassportNumber.Text = ticket.PassportNumber; tbPassportSeria.Text = ticket.PassportSeria; if (!String.IsNullOrEmpty(ticket.DeliveryCost.ToString()) && ticket.DeliveryCost != 0) { cbIsDeliveryCost.Checked = true; } //автокомплит наименования var titles = new Titles(); var availableTitles = titles.GetAllItems("Name", "ASC", null).Tables[0].Rows.Cast <DataRow>().Aggregate(String.Empty, (current, items) => current + ("\"" + items["Name"] + "\",")); AvailableTitles = availableTitles.Remove(availableTitles.Length - 1); #endregion #region Заполнение города var allCity = Application["CityList"] as List <City>; if (allCity != null) { tbCity.Text = CityHelper.CityIDToAutocompleteString(allCity.FirstOrDefault(u => u.ID == ticket.CityID)); hfCityID.Value = ticket.CityID.ToString(); var senderCity = allCity.First(u => u.ID == ticket.SenderCityID); tbSenderCity.Text = CityHelper.CityIDToAutocompleteString(senderCity); hfSenderCityID.Value = ticket.SenderCityID.ToString(); } #endregion hfWharehouse.Value = ticket.WharehouseId.ToString(); #region блок информации, заполняемой менеджером ddlStatus.DataSource = DAL.DataBaseObjects.Tickets.TicketStatuses; ddlStatus.DataTextField = "Value"; ddlStatus.DataValueField = "Key"; ddlStatus.DataBind(); ddlStatus.SelectedValue = Convert.ToString(ticket.StatusID); var ddrivers = new Drivers { StatusID = 1 }; var dataSet5 = ddrivers.GetAllActivatedDrivers(); dataSet5.Tables[0].Columns.Add("FIOAndID", typeof(string), "'(' + ID + ') ' + FirstName + ' ' + SUBSTRING(LastName,1,1) + '.' + SUBSTRING(ThirdName,1,1) + '.'"); ddlDrivers.DataSource = dataSet5; ddlDrivers.DataTextField = "FIOAndID"; ddlDrivers.DataValueField = "ID"; ddlDrivers.DataBind(); ddlDrivers.Items.Insert(0, new ListItem("Водитель не назначен", "0")); tbAgreedCost.Text = MoneyMethods.MoneySeparator(ticket.AgreedCost.ToString()); tbGruzobozCost.Text = MoneyMethods.MoneySeparator(ticket.GruzobozCost.ToString()); #region Блок блокировки полей if (currentRole.ActionControlGruzobozCost != 1) { tbGruzobozCost.Enabled = false; } if (currentRole.ActionStatusAdd != 1) { ddlStatus.Enabled = false; tbDeliveryDate.Enabled = false; tbStatusDescription.Enabled = false; } if (currentRole.ActionDriverAdd != 1) { ddlDrivers.Enabled = false; } if (currentRole.ActionAllowChangeMoneyAndCourse != 1) { tbAgreedCost.Enabled = false; tbGruzobozCost.Enabled = false; } #endregion //если id водителя 0 или -1 - водитель не назначен if (ticket.DriverID != 0 && ticket.DriverID != -1) { ddlDrivers.SelectedValue = ticket.DriverID.ToString(); } else { ddlDrivers.SelectedValue = "0"; } //если статусы На складе (перенесен), Отказ (у курьера), Возврат (на складе), Отмена (на складе), Отмена то показываем почему if (ddlStatus.SelectedValue == "7" || ddlStatus.SelectedValue == "8" || ddlStatus.SelectedValue == "4" || ddlStatus.SelectedValue == "9" || ddlStatus.SelectedValue == "10") { lblStatusDescription.Visible = true; tbStatusDescription.Visible = true; tbStatusDescription.Text = ticket.StatusDescription; } #endregion #region Ограничения на правку текстбоксов //если админ или статусы "Не обработана" или "На складе" или "На складе (перенесено)", или "Отмена" или "Отмена (на складе)" - можно изменять все поля пользователя if (currentRole.ActionDisallowEditSomeFieldInTickets != 1 && (ddlStatus.SelectedValue == "1" || ddlStatus.SelectedValue == "2" || ddlStatus.SelectedValue == "4" || ddlStatus.SelectedValue == "9" || ddlStatus.SelectedValue == "10") && currentRole.ActionDisallowTicketChangeWithoutManagerInfo != 1) { tbCity.Enabled = tbRecipientStreetNumber.Enabled = tbRecipientKorpus.Enabled = tbRecipientFirstName.Enabled = tbRecipientLastName.Enabled = tbRecipientThirdName.Enabled = tbRecipientKvartira.Enabled = tbRecipientPhone.Enabled = tbBoxesNumber.Enabled = tbDeliveryDate.Enabled = tbOtherDocuments.Enabled = tbTtnNumber.Enabled = tbTtnSeria.Enabled = tbPassportNumber.Enabled = tbPassportSeria.Enabled = tbRecipientPhone2.Enabled = tbRecipientStreet.Enabled = tbNote.Enabled = true; for (var i = 1; i <= GoodsCount; i++) { var tbGoodsDescription = (TextBox)pnlBooks.FindControl("tbGoodsDescription" + i); var tbGoodsModel = (TextBox)pnlBooks.FindControl("tbGoodsModel" + i); var tbGoodsNumber = (TextBox)pnlBooks.FindControl("tbGoodsNumber" + i); tbGoodsDescription.Enabled = true; tbGoodsModel.Enabled = true; tbGoodsNumber.Enabled = true; } } if (currentRole.ActionDisallowTicketChangeWithoutManagerInfo == 1) { ddlUserTrack.Enabled = false; tbRecipientFirstName.Enabled = false; tbRecipientLastName.Enabled = false; tbRecipientThirdName.Enabled = false; } //только админ может изменять курсы if (currentRole.ActionAllowChangeMoneyAndCourse == 1 && currentRole.ActionDisallowTicketChangeWithoutManagerInfo != 1) { cbIsDeliveryCost.Enabled = tbDeliveryCost.Enabled = true; for (var i = 1; i <= GoodsCount; i++) { var tbGoodsCost = (TextBox)pnlBooks.FindControl("tbGoodsCost" + i); tbGoodsCost.Enabled = true; } } #endregion } if (!String.IsNullOrEmpty(hfCityID.Value)) { var coefficientDeviationCost = Convert.ToDouble(BackendHelper.TagToValue("coefficient_deviation_cost")); var city = new City { ID = Convert.ToInt32(hfCityID.Value) }; city.GetById(); var district = new Districts { ID = Convert.ToInt32(city.DistrictID) }; district.GetById(); lblCityCost.Text = MoneyMethods.MoneySeparatorForCityTableView((city.DistanceFromCity * Convert.ToDecimal(coefficientDeviationCost)).ToString()); lblCityDeliveryDate.Text = DistrictsHelper.DeliveryDateStringToRuss(DistrictsHelper.DeliveryDateString(city.DistrictID)); lblCityDeliveryTerms.Text = DistrictsHelper.DeliveryTermsToRuss(DistrictsHelper.DeliveryTerms(city.DistrictID)); } }