private void SetCar(Ajancy.Car car) { if (car == null) { this.drpCarType.SelectedIndex = 0; this.txtCarVIN.Text = null; this.txtCarModel.Text = null; this.txtCarColor.Text = null; this.txtCarEngineNo.Text = null; this.txtCarChassisNo.Text = null; this.drpFuelType.SelectedValue = null; this.drpGASProvider.SelectedIndex = 0; SetPlateNumber(null); } else { this.drpCarType.Items.Add(car.CarType.TypeName); this.txtCarVIN.Text = car.VIN; this.txtCarModel.Text = car.Model; this.txtCarColor.Text = car.Color; this.txtCarEngineNo.Text = car.EngineNo; this.txtCarChassisNo.Text = car.ChassisNo; this.drpFuelType.SelectedValue = car.FuelType.ToString(); this.drpGASProvider.SelectedValue = car.GASProvider.GetValueOrDefault().ToString(); SetPlateNumber(car.CarPlateNumbers.Last<Ajancy.CarPlateNumber>().PlateNumber); } }
private void SetFuelCard(Ajancy.FuelCard fuelCard) { if (fuelCard == null) { this.txtFuelCardPAN.Text = null; this.drpFuelCardType.SelectedIndex = 0; } else { this.txtFuelCardPAN.Text = fuelCard.PAN; this.drpFuelCardType.SelectedValue = fuelCard.CardType.ToString(); } }
private void SetDrivingLicense(Ajancy.DrivingLicense drivingLicense) { if (drivingLicense == null) { this.txtDrivingLicenseNo.Text = null; this.txtDrivingLicenseDate.Text = null; this.txtDrivingLicensePlace.Text = null; this.drpDrivingLicenseType.SelectedIndex = 0; } else { this.txtDrivingLicenseNo.Text = drivingLicense.DrivingLicenseNo; this.txtDrivingLicenseDate.SetDate(drivingLicense.ExportDate); this.txtDrivingLicensePlace.Text = drivingLicense.ExportPlace; this.drpDrivingLicenseType.SelectedValue = drivingLicense.Type.ToString(); } }
private void SetCarOwner(Ajancy.Person carOwner) { if (carOwner == null) { this.txtOwnerNationalCode.Text = null; this.txtOwnerName.Text = null; this.txtOwnerFamily.Text = null; } else { this.txtOwnerNationalCode.Text = carOwner.NationalCode; this.txtOwnerName.Text = carOwner.FirstName; this.txtOwnerFamily.Text = carOwner.LastName; } }
private void LoadDriverCars(int driverCertificationId, Ajancy.Kimia_Ajancy db) { var cars = from dcc in db.DriverCertificationCars join cpn in db.CarPlateNumbers on dcc.CarPlateNumberID equals cpn.CarPlateNumberID from pn in db.PlateNumbers.Where(number => number.PlateNumberID == cpn.PlateNumberID).DefaultIfEmpty() from zpn in db.ZonePlateNumbers.Where(number => number.ZonePlateNumberID == cpn.ZonePlateNumberID).DefaultIfEmpty() join c in db.Cars on cpn.CarID equals c.CarID join ct in db.CarTypes on c.CarTypeID equals ct.CarTypeID where dcc.DriverCertificationID == driverCertificationId select new { dcc.DriverCertificationCarID, ct.TypeName, IsZoneType = cpn.ZonePlateNumberID.HasValue, ZCity = zpn.City.Name, ZNumber = zpn.Number, pn.TwoDigits, pn.ThreeDigits, pn.Alphabet, pn.RegionIdentifier, c.VIN, DccLock = dcc.LockOutDate }; System.Collections.ArrayList list = new System.Collections.ArrayList(); foreach (var item in cars) { var jdStatus = (from jd in db.AjancyDrivers where jd.DriverCertificationCarID == item.DriverCertificationCarID orderby jd.AjancyDriverID descending select new { jd.LockOutDate }).Take(1); foreach (var jd in jdStatus) { list.Add(new { item.TypeName, item.IsZoneType, item.ZCity, item.ZNumber, item.TwoDigits, item.ThreeDigits, item.Alphabet, item.RegionIdentifier, item.VIN, Status = (item.DccLock == null && jd.LockOutDate == null) ? "فعال" : "غیرفعال" }); } } this.lstCars.DataSource = list; this.lstCars.DataBind(); }
private void SetPerson(Ajancy.Person person) { if (person != null) { this.drpProvince.SelectedValue = person.User.ProvinceID.ToString(); this.drpProvince_SelectedIndexChanged(this, new EventArgs()); this.drpCity.SelectedValue = person.User.CityID.ToString(); this.txtFirstName.Text = person.FirstName; this.txtLastName.Text = person.LastName; this.txtFather.Text = person.Father; this.txtNationalCode.Text = person.NationalCode; this.txtBirthCertificateNo.Text = person.BirthCertificateNo; this.txtBirthCertificateSerial.Text = person.BirthCertificateSerial; this.txtBirthCertificateSerie.Text = person.BirthCertificateSerie; this.drpBirthCertificateAlfa.SelectedValue = person.BirthCertificateAlfa; this.drpGender.SelectedValue = person.Gender.GetValueOrDefault().ToString(); this.txtBirthDate.SetDate(person.BirthDate); this.txtBirthPlace.Text = person.BirthPlace; this.txtBirthCertificatePlace.Text = person.BirthCertificatePlace; this.drpMarriage.SelectedValue = person.Marriage.GetValueOrDefault().ToString(); this.txtFamilyMembersCount.Text = person.FamilyMembersCount; this.drpEducation.SelectedValue = person.Education.GetValueOrDefault().ToString(); this.drpMilitaryService.SelectedValue = person.MilitaryService.GetValueOrDefault().ToString(); this.drpReligion.SelectedValue = person.Religion.GetValueOrDefault().ToString(); this.txtSubreligion.Text = person.Subreligion; this.drpJobStatus.SelectedValue = person.JobStatus.GetValueOrDefault().ToString(); this.txtPhone.Text = person.Phone; this.txtMobile.Text = person.Mobile; this.txtPostalCode.Text = person.PostalCode; this.txtAddress.Text = person.Address; } else { this.drpProvince.SelectedIndex = 0; this.drpCity.SelectedIndex = 0; this.txtFirstName.Text = null; this.txtLastName.Text = null; this.txtFather.Text = null; this.txtBirthCertificateNo.Text = null; this.txtBirthCertificateSerial.Text = null; this.txtBirthCertificateSerie.Text = null; this.drpBirthCertificateAlfa.SelectedIndex = 0; this.drpGender.SelectedIndex = 0; this.txtBirthDate.Text = null; this.txtBirthPlace.Text = null; this.txtBirthCertificatePlace.Text = null; this.drpMarriage.SelectedIndex = 0; this.txtFamilyMembersCount.Text = null; this.drpEducation.SelectedIndex = 0; this.drpMilitaryService.SelectedIndex = 0; this.drpReligion.SelectedIndex = 0; this.txtSubreligion.Text = null; this.drpJobStatus.SelectedIndex = 0; this.txtPhone.Text = null; this.txtMobile.Text = null; this.txtPostalCode.Text = null; this.txtAddress.Text = null; } }
private void SetPlateNumber(Ajancy.ZonePlateNumber plateNumber) { if (plateNumber != null) { this.txtCarPlateNumber_5.Text = plateNumber.Number; this.drpCarPlateNumberProvince.SelectedValue = plateNumber.City.ProvinceID.ToString(); this.drpCarPlateNumberProvince_SelectedIndexChanged(this, new EventArgs()); this.drpCarPlateNumberCity.SelectedValue = plateNumber.CityID.ToString(); } else { this.txtCarPlateNumber_5.Text = null; this.drpCarPlateNumberProvince.SelectedIndex = 0; this.drpCarPlateNumberCity.SelectedIndex = 0; } }
private void SetPerson(Ajancy.Person person) { if (person != null) { this.ViewState["PersonID"] = person.PersonID; this.txtFirstName.Text = person.FirstName; this.txtLastName.Text = person.LastName; this.txtNationalCode.Text = person.NationalCode; this.drpGender.SelectedValue = person.Gender.GetValueOrDefault().ToString(); this.txtMobile.Text = person.Mobile; } else { this.ViewState["PersonID"] = null; this.txtFirstName.Text = null; this.txtLastName.Text = null; this.drpGender.SelectedIndex = 0; this.txtMobile.Text = null; } }
private void SetAjancy(Ajancy.Ajancy ajancy) { if (ajancy == null) { this.ViewState["AjancyID"] = null; this.drpAjancyType.SelectedIndex = 0; this.drpProvince.SelectedIndex = 0; this.drpCity.SelectedIndex = 0; this.drpBusinessLicenseType.SelectedIndex = 0; this.txtAjancyName.Text = null; this.txtBusinessLicenseNo.Text = null; this.txtMemberShipCode.Text = null; this.txtNationalCardBarCode.Text = null; this.txtSerialNo.Text = null; this.txtCategoryCode.Text = null; this.txtISIC.Text = null; this.drpOfficePosition.SelectedIndex = 0; this.txtOfficeLevel.Text = null; this.txtOfficeSpace.Text = null; this.txtBalconySpace.Text = null; this.txtBalconyHeight.Text = null; this.txtParkingSpace.Text = null; this.drpParkingState.SelectedIndex = 0; this.txtBusinessScope.Text = null; this.txtPoliceStation.Text = null; this.drpMayor.SelectedIndex = 0; this.drpBusinessLicenseType.SelectedIndex = 0; this.txtBusinessPlacePhone.Text = null; this.txtRegisteredPelak.Text = null; this.txtBluePelak.Text = null; this.drpEstateType.SelectedIndex = 0; this.drpDocumentType.SelectedIndex = 0; this.txtPlaceOwner.Text = null; this.txtPlaceAddress.Text = null; this.txtPlacePostalCode.Text = null; this.lstUtility.ClearSelection(); SetPartners(null); } else { this.ViewState["AjancyID"] = ajancy.AjancyID; this.drpAjancyType.SelectedValue = ajancy.AjancyType.ToString(); //this.drpProvince.SelectedValue = ajancy.City.ProvinceID.ToString(); this.drpCity.SelectedValue = ajancy.CityID.ToString(); this.drpBusinessLicenseType.SelectedValue = ajancy.BusinessLicenseType.ToString(); this.txtAjancyName.Text = ajancy.AjancyName; this.drpOfficePosition.SelectedValue = ajancy.OfficePosition.ToString(); this.txtOfficeLevel.Text = ajancy.OfficeLevel; this.txtOfficeSpace.Text = ajancy.OfficeSpace; this.txtBalconySpace.Text = ajancy.BalconySpace; this.txtBalconyHeight.Text = ajancy.BalconyHeight; this.txtParkingSpace.Text = ajancy.ParkingSpace; this.drpParkingState.SelectedIndex = ajancy.ParkingState.GetValueOrDefault() ? 0 : 1; this.txtBusinessScope.Text = ajancy.BusinessScope; this.txtPoliceStation.Text = ajancy.PoliceStation; this.drpMayor.SelectedIndex = ajancy.Mayor.GetValueOrDefault() == 0 ? 0 : ajancy.Mayor.GetValueOrDefault(); this.txtBusinessPlacePhone.Text = ajancy.Phone; this.txtRegisteredPelak.Text = ajancy.RegisteredPelak; this.txtBluePelak.Text = ajancy.BluePelak; this.txtPlacePostalCode.Text = ajancy.PostalCode; this.txtPlaceAddress.Text = ajancy.Address; this.drpEstateType.SelectedValue = ajancy.EstateType.ToString(); this.drpDocumentType.SelectedValue = ajancy.DocumentType.ToString(); this.txtPlaceOwner.Text = ajancy.PlaceOwner; Ajancy.BusinessLicense businessLicense = ajancy.BusinessLicenses.LastOrDefault<Ajancy.BusinessLicense>(); if (businessLicense != null) { this.txtBusinessLicenseNo.Text = businessLicense.BusinessLicenseNo; this.txtMemberShipCode.Text = businessLicense.MemberShipCode; this.txtNationalCardBarCode.Text = businessLicense.NationalCardBarCode; this.txtSerialNo.Text = businessLicense.SerialNo; this.txtCategoryCode.Text = businessLicense.CategoryCode; this.txtISIC.Text = businessLicense.ISIC; Ajancy.BusinessLicenseRevival businessLicenseRevival = businessLicense.BusinessLicenseRevivals.LastOrDefault<Ajancy.BusinessLicenseRevival>(); if (businessLicenseRevival != null) { this.txtStartDate.SetDate(businessLicenseRevival.StartDate); this.txtEndDate.SetDate(businessLicenseRevival.EndDate); } } SetPartners(ajancy.AjancyPartners.Where<Ajancy.AjancyPartner>(jp => jp.UsersInRole.RoleID == (short)Public.Role.AjancyPartner).ToList<Ajancy.AjancyPartner>()); foreach (ListItem item in this.lstUtility.Items) { item.Selected = ajancy.AjancyUtilities.Any<Ajancy.AjancyUtility>(u => u.Utility == Public.ToByte(item.Value)); } } }
public static string PlateNumberRenderToHTML(Ajancy.PlateNumber plateNumber) { if (plateNumber != null) { return string.Format("<div style='height: 28px;width: 100%;'><div style='float: right;width: 23px;'>{3}</div><div style='float: right;width: 23px;'>ایران</div><div style='float: right;width: 30px;'>{2}</div><div style='float: right;width: 15px;'>{1}</div><div style='float: right;width: 23px;'>{0}</div></div>", plateNumber.TwoDigits, GetAlphabet(plateNumber.Alphabet), plateNumber.ThreeDigits, plateNumber.RegionIdentifier); } return null; }
private void SetPerson(Ajancy.Person person) { if (person == null) { this.ViewState["PersonID"] = null; this.txtFirstName.Text = null; this.txtLastName.Text = null; this.txtFather.Text = null; this.txtBirthCertificateNo.Text = null; this.drpGender.SelectedIndex = 0; this.txtBirthPlace.Text = null; this.drpMarriage.SelectedIndex = 0; this.txtPhone.Text = null; this.txtMobile.Text = null; this.txtPostalCode.Text = null; this.txtAddress.Text = null; SetCarOwner(null); SetCar(null); SetFuelCard(null); //SetFormerCar(null); } else { if (person.User.ProvinceID != Public.ActiveUserRole.User.ProvinceID) // This is driver of another province { DisposeContext(); Response.Redirect("~/Message.aspx?mode=15"); } this.ViewState["PersonID"] = person.PersonID; this.txtFirstName.Text = person.FirstName; this.txtLastName.Text = person.LastName; this.txtFather.Text = person.Father; this.txtNationalCode.Text = person.NationalCode; this.txtBirthCertificateNo.Text = person.BirthCertificateNo; this.drpGender.SelectedValue = person.Gender.GetValueOrDefault().ToString(); this.txtBirthPlace.Text = person.BirthPlace; this.drpMarriage.SelectedValue = person.Marriage.GetValueOrDefault().ToString(); this.txtPhone.Text = person.Phone; this.txtMobile.Text = person.Mobile; this.txtPostalCode.Text = person.PostalCode; this.txtAddress.Text = person.Address; if (person.DriverCertifications.Count > 0) { Ajancy.DriverCertification driverCertification = person.DriverCertifications.SingleOrDefault<Ajancy.DriverCertification>(dc => dc.CertificationType == (byte)Public.AjancyType.TaxiAjancy); Ajancy.DriverCertificationCar driverCertificationCar = driverCertification.DriverCertificationCars.Last<Ajancy.DriverCertificationCar>(); SetCarOwner(driverCertificationCar.CarPlateNumber.Person); SetCar(driverCertificationCar.CarPlateNumber.Car); SetFuelCard(driverCertificationCar.CarPlateNumber.Car.FuelCards.Last<Ajancy.FuelCard>()); string ajancyId = driverCertificationCar.AjancyDrivers.Last<Ajancy.AjancyDriver>().AjancyID.ToString(); if (this.drpAjancies.Items.FindByValue(ajancyId) != null) { this.drpAjancies.SelectedValue = ajancyId; } //this.drpAjancies.SelectedValue = driverCertificationCar.AjancyDrivers.Last<Ajancy.AjancyDriver>(jd => jd.LockOutDate == null).AjancyID.ToString(); this.txtDriverCertificationNo.Text = driverCertification.DriverCertificationNo; this.drpDriverCertificationNo.SelectedIndex = string.IsNullOrEmpty(driverCertification.DriverCertificationNo) ? 1 : 0; } } }
private void SetPerson_2(Ajancy.Person person) { if (person == null) { this.ViewState["PersonID_2"] = null; this.txtFirstName_2.Text = null; this.txtLastName_2.Text = null; SetCarOwner_2(null); SetCar_2(null); SetFuelCard_2(null); } else { this.ViewState["PersonID_2"] = person.PersonID; this.txtFirstName_2.Text = person.FirstName; this.txtLastName_2.Text = person.LastName; this.txtNationalCode_2.Text = person.NationalCode; if (person.DriverCertifications.Count > 0) { Ajancy.DriverCertification driverCertification = person.DriverCertifications.SingleOrDefault<Ajancy.DriverCertification>(dc => dc.CertificationType == (byte)Public.AjancyType.Academy); if (driverCertification != null) { if (this.txtNationalCode.Text == this.txtNationalCode_2.Text) // Self replacement for a person who is driver { DisposeContext(); Response.Redirect(string.Format("~/Academy/SelfReplacement.aspx?id={0}", TamperProofString.QueryStringEncode(person.PersonID.ToString()))); } if (Request.QueryString["nc1"] == null && Request.QueryString["nc2"] == null) // Add mode { if (Public.ActiveUserRole.RoleID == (short)Public.Role.AcademyProvince) // Is ProvinceManager { if (person.User.ProvinceID != Public.ActiveUserRole.User.ProvinceID) { DisposeContext(); Response.Redirect("~/Message.aspx?mode=15"); // This is a driver of an other province } else if (person.User.CityID.Value.ToString() != this.drpCity.SelectedValue) { this.drpCity_2.SelectedValue = person.User.CityID.Value.ToString(); this.drpCity.SelectedIndex = this.drpCity_2.SelectedIndex; LoadAjancies(true); } } else if (Public.ActiveUserRole.RoleID == (short)Public.Role.CityManager && person.User.CityID != Public.ActiveUserRole.User.CityID) { DisposeContext(); Response.Redirect("~/Message.aspx?mode=13"); // This is a driver of an other city } } Ajancy.DriverCertificationCar driverCertificationCar = driverCertification.DriverCertificationCars.Last<Ajancy.DriverCertificationCar>(dcc => dcc.LockOutDate == null); try { this.drpAjancies_2.SelectedValue = driverCertificationCar.AjancyDrivers.Last<Ajancy.AjancyDriver>(jd => jd.LockOutDate == null).AjancyID.ToString(); } catch { } SetCarOwner_2(driverCertificationCar.CarPlateNumber.Person); SetCar_2(driverCertificationCar.CarPlateNumber.Car); SetFuelCard_2(driverCertificationCar.CarPlateNumber.Car.FuelCards.Last<Ajancy.FuelCard>()); } } } }
private void LogIn(Ajancy.UsersInRole userInRole, string[] roleParts) { Ajancy.User user = new Ajancy.User { UserID = userInRole.UserID, CityID = userInRole.User.Person.User.CityID.GetValueOrDefault(), ProvinceID = userInRole.User.Person.User.ProvinceID, Person = new Ajancy.Person { PersonID = userInRole.User.PersonID, FirstName = userInRole.User.Person.FirstName, LastName = userInRole.User.Person.LastName }, City = new Ajancy.City { CityID = userInRole.User.Person.User.CityID.GetValueOrDefault(), ProvinceID = userInRole.User.Person.User.ProvinceID, Name = userInRole.User.Person.User.City.Name }, Province = new Ajancy.Province { ProvinceID = userInRole.User.Person.User.ProvinceID, Name = userInRole.User.Person.User.Province.Name } }; this.DisposeContext(); this.Session["UserRole"] = new Ajancy.UsersInRole { UserRoleID = userInRole.UserRoleID, RoleID = userInRole.RoleID, User = user }; if (userInRole.RoleID == (short)Public.Role.AjancyManager) { this.Session["Ajancy"] = new Ajancy.Ajancy { AjancyID = int.Parse(roleParts[1]), AjancyType = byte.Parse(roleParts[2]), AjancyName = roleParts[3] }; } FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, this.txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes(30), true, userInRole.RoleID.ToString()); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket))); Response.Redirect(FormsAuthentication.GetRedirectUrl(this.txtUserName.Text, true)); }
private void SetFormerBusiness(Ajancy.FormerBusiness formerBusiness) { if (formerBusiness != null) { this.txtFormerBusinessLicenseNo.Text = formerBusiness.BusinessLicenseNo; this.txtFormerBusinessLicenseDate.SetDate(formerBusiness.BusinessLicenseDate.GetValueOrDefault()); this.txtFormerBusinessStartDate.SetDate(formerBusiness.BusinessStartDate.GetValueOrDefault()); this.txtFormerBusinessBoard.Text = formerBusiness.Board; } else { this.txtFormerBusinessLicenseNo.Text = null; this.txtFormerBusinessLicenseDate.Text = null; this.txtFormerBusinessStartDate.Text = null; this.txtFormerBusinessBoard.Text = null; } }
private void SetAjancy(Ajancy.Ajancy ajancy) { if (ajancy == null) { this.ViewState["AjancyID"] = null; this.drpAjancyType.SelectedIndex = 0; this.drpProvince.SelectedIndex = 0; this.drpCity.SelectedIndex = 0; this.drpBusinessLicenseType.SelectedIndex = 0; this.drpOfficePosition.SelectedIndex = 0; this.txtOfficeLevel.Text = null; this.txtOfficeSpace.Text = null; this.txtBalconySpace.Text = null; this.txtBalconyHeight.Text = null; this.txtParkingSpace.Text = null; this.drpParkingState.SelectedIndex = 0; this.txtBusinessScope.Text = null; this.txtPoliceStation.Text = null; this.drpMayor.SelectedIndex = 0; this.drpBusinessLicenseType.SelectedIndex = 0; this.txtBusinessPlacePhone.Text = null; this.txtRegisteredPelak.Text = null; this.txtBluePelak.Text = null; this.drpEstateType.SelectedIndex = 0; this.drpDocumentType.SelectedIndex = 0; this.txtPlaceOwner.Text = null; this.txtPlaceAddress.Text = null; this.txtPlacePostalCode.Text = null; this.lstUtility.ClearSelection(); SetFormerBusiness(null); SetPartners(null); } else { this.ViewState["AjancyID"] = ajancy.AjancyID; this.drpAjancyType.SelectedValue = ajancy.AjancyType.ToString(); //this.drpProvince.SelectedValue = ajancy.City.ProvinceID.ToString(); this.drpCity.SelectedValue = ajancy.CityID.ToString(); this.drpBusinessLicenseType.SelectedValue = ajancy.BusinessLicenseType.ToString(); this.drpOfficePosition.SelectedValue = ajancy.OfficePosition.ToString(); this.txtOfficeLevel.Text = ajancy.OfficeLevel; this.txtOfficeSpace.Text = ajancy.OfficeSpace; this.txtBalconySpace.Text = ajancy.BalconySpace; this.txtBalconyHeight.Text = ajancy.BalconyHeight; this.txtParkingSpace.Text = ajancy.ParkingSpace; this.drpParkingState.SelectedIndex = ajancy.ParkingState.GetValueOrDefault() ? 0 : 1; this.txtBusinessScope.Text = ajancy.BusinessScope; this.txtPoliceStation.Text = ajancy.PoliceStation; this.drpMayor.SelectedValue = ajancy.Mayor.ToString(); this.txtBusinessPlacePhone.Text = ajancy.Phone; this.txtRegisteredPelak.Text = ajancy.RegisteredPelak; this.txtBluePelak.Text = ajancy.BluePelak; this.txtPlacePostalCode.Text = ajancy.PostalCode; this.txtPlaceAddress.Text = ajancy.Address; this.txtWaterBillSerial.Text = ajancy.WaterBillSerial; this.txtElectricityBillSerial.Text = ajancy.ElectricityBillSerial; this.txtGasBillSerial.Text = ajancy.GasBillSerial; this.drpEstateType.SelectedValue = ajancy.EstateType.ToString(); this.drpDocumentType.SelectedValue = ajancy.DocumentType.ToString(); this.txtPlaceOwner.Text = ajancy.PlaceOwner; SetFormerBusiness(ajancy.FormerBusiness); SetPartners(ajancy.AjancyPartners.Where<Ajancy.AjancyPartner>(jp => jp.UsersInRole.RoleID == (short)Public.Role.AjancyPartner).ToList<Ajancy.AjancyPartner>()); foreach (ListItem item in this.lstUtility.Items) { item.Selected = ajancy.AjancyUtilities.Any<Ajancy.AjancyUtility>(u => u.Utility == Public.ToByte(item.Value)); } } }
//protected void btnSave_Click(object sender, EventArgs e) //{ // if (this.Page.IsValid) // { // db = new Ajancy.Kimia_Ajancy(Public.CONNECTIONSTRING); // dlo = new DataLoadOptions(); // dlo.LoadWith<Ajancy.DriverCertification>(dc => dc.DriverCertificationCars); // dlo.LoadWith<Ajancy.DriverCertificationCar>(dcc => dcc.CarPlateNumber); // dlo.LoadWith<Ajancy.CarPlateNumber>(cpn => cpn.Car); // dlo.LoadWith<Ajancy.Car>(c => c.FuelCards); // db.LoadOptions = dlo; // Ajancy.Car car = db.Cars.FirstOrDefault<Ajancy.Car>(c => c.CarTypeID == Public.ToByte(this.drpCarType.SelectedValue) && // c.EngineNo == this.txtCarEngineNo.Text.Trim() && // c.ChassisNo == this.txtCarChassisNo.Text.Trim()); // if (car != null) // { // foreach (var cpn in car.CarPlateNumbers) // { // foreach (var dcc in cpn.DriverCertificationCars) // { // if (dcc.LockOutDate == null) // { // this.lblMessage.Text = "خودرو مورد نظر با این شماره موتور و شماره شاسی متعلق به شخص دیگری میباشد"; // return; // } // } // } // } // if (db.FuelCards.Any<Ajancy.FuelCard>(fc => fc.PAN == this.txtFuelCardPAN.Text.Trim())) // { // this.lblMessage.Text = "شماره PAN کارت سوخت خودرو قبلا برای خودرو دیگری ثبت شده"; // return; // } // Ajancy.PlateNumber plateNumber = db.PlateNumbers.FirstOrDefault<Ajancy.PlateNumber>(pl => pl.TwoDigits == this.txtCarPlateNumber_1.Text.Trim() && // pl.Alphabet == this.drpCarPlateNumber.SelectedValue && // pl.ThreeDigits == this.txtCarPlateNumber_2.Text.Trim() && // pl.RegionIdentifier == this.txtCarPlateNumber_3.Text.Trim()); // if (plateNumber != null) // { // foreach (Ajancy.CarPlateNumber cpn in plateNumber.CarPlateNumbers) // { // foreach (var dcc in cpn.DriverCertificationCars) // { // if (dcc.LockOutDate == null) // { // this.lblMessage.Text = "شماره پلاک وارد شده متعلق به شخص دیگری میباشد"; // return; // } // } // } // } // else // { // plateNumber = new Ajancy.PlateNumber // { // TwoDigits = this.txtCarPlateNumber_1.Text.Trim(), // Alphabet = this.drpCarPlateNumber.SelectedValue, // ThreeDigits = this.txtCarPlateNumber_2.Text.Trim(), // RegionIdentifier = this.txtCarPlateNumber_3.Text.Trim(), // }; // } // Ajancy.Person person = new Ajancy.Person(); // if (this.ViewState["PersonID"] == null) // { // Ajancy.User user = new Ajancy.User(); // user.UserName = this.txtNationalCode.Text.Trim(); // user.ProvinceID = Public.ActiveUserRole.User.ProvinceID; // user.CityID = Public.ActiveUserRole.User.CityID; // user.SubmitDate = DateTime.Now; // user.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.TaxiDriver, MembershipDate = DateTime.Now }); // person.User = user; // person.NationalCode = this.txtNationalCode.Text.Trim(); // person.SubmitDate = DateTime.Now; // db.Persons.InsertOnSubmit(person); // } // else // { // person = db.Persons.FirstOrDefault<Ajancy.Person>(p => p.PersonID == Public.ToInt(this.ViewState["PersonID"])); // person.User.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.TaxiDriver, MembershipDate = DateTime.Now }); // } // #region FormerCar // //Ajancy.Car formerCar = new Ajancy.Car(); // //Ajancy.FuelCard formerFuelCard = new Ajancy.FuelCard(); // //if (HasFormerCar()) // //{ // // if (db.FuelCards.Any<Ajancy.FuelCard>(fc => fc.PAN == this.txtFormerCarPAN.Text.Trim())) // // { // // this.lblMessage.Text = "شماره PAN کارت سوخت خودرو قبلی مربوط به دفترچه صلاحیت برای خودرو دیگری ثبت شده"; // // return; // // } // // formerCar = db.Cars.FirstOrDefault<Ajancy.Car>(c => c.CarTypeID == Public.ToByte(this.drpFormerCarType.SelectedValue) && // // c.EngineNo == this.txtFormerCarEngineNo.Text.Trim() && // // c.ChassisNo == this.txtFormerCarChassisNo.Text.Trim()); // // if (formerCar == null) // // { // // formerCar = new Ajancy.Car(); // // formerCar.CarTypeID = Public.ToByte(this.drpFormerCarType.SelectedValue); // // formerCar.Model = this.txtFormerCarModel.Text.Trim(); // // formerCar.EngineNo = this.txtFormerCarEngineNo.Text.Trim(); // // formerCar.ChassisNo = this.txtFormerCarChassisNo.Text.Trim(); // // formerCar.VIN = this.txtFormerCarVIN.Text.Trim(); // // formerCar.FuelType = Public.ToByte(this.drpFormerCarFuelType.SelectedValue); // // db.Cars.InsertOnSubmit(formerCar); // // } // // formerFuelCard.CardType = Public.ToByte(this.drpFormerCarFuelCardType.SelectedValue); // // formerFuelCard.PAN = this.txtFormerCarPAN.Text.Trim(); // // formerFuelCard.SubmitDate = DateTime.Now; // // formerFuelCard.DiscardDate = DateTime.Now; // // formerCar.FuelCards.Add(formerFuelCard); // //} // #endregion // person.FirstName = this.txtFirstName.Text.Trim(); // person.LastName = this.txtLastName.Text.Trim(); // person.Father = this.txtFather.Text.Trim(); // person.BirthCertificateNo = this.txtBirthCertificateNo.Text.Trim(); // person.BirthCertificateSerial = this.txtBirthCertificateSerial.Text.Trim(); // person.BirthCertificateSerie = this.txtBirthCertificateSerie.Text.Trim(); // person.BirthCertificateAlfa = this.drpBirthCertificateAlfa.SelectedValue; // person.Gender = Public.ToByte(this.drpGender.SelectedValue); // person.Marriage = Public.ToByte(this.drpMarriage.SelectedValue); // person.BirthDate = this.txtBirthDate.GeorgianDate.Value; // person.BirthPlace = this.txtBirthPlace.Text.Trim(); // person.BirthCertificatePlace = this.txtBirthCertificatePlace.Text.Trim(); // person.FamilyMembersCount = this.txtFamilyMembersCount.Text.Trim(); // person.Education = Public.ToByte(this.drpEducation.SelectedValue); // person.MilitaryService = Public.ToByte(this.drpMilitaryService.SelectedValue); // person.Religion = Public.ToByte(this.drpReligion.SelectedValue); // person.Subreligion = this.txtSubreligion.Text.Trim(); // person.JobStatus = Public.ToByte(this.drpJobStatus.SelectedValue); // person.Phone = this.txtPhone.Text.Trim(); // person.Mobile = this.txtMobile.Text.Trim(); // person.PostalCode = this.txtPostalCode.Text.Trim(); // person.Address = this.txtAddress.Text.Trim(); // person.TraceCode = Public.GetTraceKey(); // person.FormerJob = this.txtFormerJob.Text.Trim(); // person.FormerJobType = Public.ToByte(this.drpFormerJobType.SelectedValue); // Ajancy.DrivingLicense drivingLicense = new Ajancy.DrivingLicense // { // DrivingLicenseNo = this.txtDrivingLicenseNo.Text.Trim(), // ExportDate = this.txtDrivingLicenseDate.GeorgianDate.Value, // ExportPlace = this.txtDrivingLicensePlace.Text.Trim(), // Type = Public.ToByte(this.drpDrivingLicenseType.SelectedValue) // }; // person.DrivingLicenses.Add(drivingLicense); // car = new Ajancy.Car // { // CarTypeID = Public.ToByte(this.drpCarType.SelectedValue), // Model = this.txtCarModel.Text.Trim(), // Color = this.txtCarColor.Text.Trim(), // EngineNo = this.txtCarEngineNo.Text.Trim(), // ChassisNo = this.txtCarChassisNo.Text.Trim(), // GASProvider = Public.ToByte(this.drpGASProvider.SelectedValue), // FuelType = Public.ToByte(this.drpFuelType.SelectedValue) // }; // Ajancy.FuelCard fuelCard = new Ajancy.FuelCard // { // CardType = Public.ToByte(this.drpFuelCardType.SelectedValue), // PAN = this.txtFuelCardPAN.Text.Trim(), // SubmitDate = DateTime.Now // }; // car.FuelCards.Add(fuelCard); // db.Cars.InsertOnSubmit(car); // Ajancy.DriverCertification driverCertification = new Ajancy.DriverCertification // { // DriverCertificationNo = string.IsNullOrEmpty(this.txtDriverCertificationNo.Text.Trim()) ? null : this.txtDriverCertificationNo.Text.Trim(), // CertificationType = Public.ActiveAjancy.AjancyType, // SubmitDate = DateTime.Now // }; // //if (HasFormerCar()) // //{ // // driverCertification.DriverCertificationCars.Add(new Ajancy.DriverCertificationCar { CarPlateNumber = new Ajancy.CarPlateNumber { Car = formerCar, Person = person }, SubmitDate = DateTime.Now, LockOutDate = DateTime.Now }); // //} // Ajancy.CarPlateNumber carPlateNumber = new Ajancy.CarPlateNumber { Car = car, PlateNumber = plateNumber, VIN = this.txtCarVIN.Text.Trim(), Person = person }; // Ajancy.DriverCertificationCar driverCertificationCar = new Ajancy.DriverCertificationCar { CarPlateNumber = carPlateNumber, SubmitDate = DateTime.Now }; // driverCertification.DriverCertificationCars.Add(driverCertificationCar); // db.AjancyDrivers.InsertOnSubmit(new Ajancy.AjancyDriver { AjancyID = Public.ActiveAjancy.AjancyID, DriverCertificationCar = driverCertificationCar, MembershipDate = DateTime.Now }); // person.DriverCertifications.Add(driverCertification); // // Sets the owner of the car // Ajancy.Person carOwner = null; // if (!string.IsNullOrEmpty(this.txtOwnerName.Text.Trim()) && !string.IsNullOrEmpty(this.txtOwnerFamily.Text.Trim()) && !string.IsNullOrEmpty(this.txtOwnerNationalCode.Text.Trim()) && !this.txtOwnerNationalCode.Text.Trim().Equals(person.NationalCode)) // { // carOwner = db.Persons.FirstOrDefault<Ajancy.Person>(p => p.NationalCode == this.txtOwnerNationalCode.Text.Trim()); // if (carOwner == null) // { // carOwner = new Ajancy.Person { NationalCode = this.txtOwnerNationalCode.Text.Trim(), FirstName = this.txtOwnerName.Text.Trim(), LastName = this.txtOwnerFamily.Text.Trim(), SubmitDate = DateTime.Now, TraceCode = Public.GetTraceKey() }; // Ajancy.User userOwner = new Ajancy.User(); // userOwner.UserName = this.txtOwnerNationalCode.Text.Trim(); // if ((short)Public.ActiveUserRole.RoleID == (short)Public.Role.AjancyManager) // { // userOwner.ProvinceID = Public.ActiveUserRole.User.ProvinceID; // userOwner.CityID = Public.ActiveUserRole.User.CityID; // } // else // { // userOwner.ProvinceID = person.User.ProvinceID; // userOwner.CityID = person.User.CityID; // } // userOwner.SubmitDate = DateTime.Now; // userOwner.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now }); // carOwner.User = userOwner; // db.Persons.InsertOnSubmit(carOwner); // } // else // { // if (!carOwner.User.UsersInRoles.Any<Ajancy.UsersInRole>(ur => ur.RoleID == (short)Public.Role.CarOwner)) // { // carOwner.User.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now }); // } // } // person.CarPlateNumbers.Remove(carPlateNumber); // carOwner.CarPlateNumbers.Add(carPlateNumber); // } // try // { // db.SubmitChanges(); // Response.Redirect("~/Message.aspx?mode=12"); // } // catch (Exception ex) // { // if (ex.Message.Contains("DrivingLicenseNo")) // { // this.lblMessage.Text = "شماره گواهینامه رانندگی تکراری میباشد"; // } // else // { // throw ex; // } // } // } //} //protected void btnEdit_Click(object sender, EventArgs e) //{ // if (this.Page.IsValid) // { // db = new Ajancy.Kimia_Ajancy(Public.CONNECTIONSTRING); // dlo = new DataLoadOptions(); // dlo.LoadWith<Ajancy.Person>(p => p.DrivingLicenses); // dlo.LoadWith<Ajancy.Person>(p => p.DriverCertifications); // dlo.LoadWith<Ajancy.DriverCertification>(dc => dc.DriverCertificationCars); // dlo.LoadWith<Ajancy.DriverCertificationCar>(dcc => dcc.CarPlateNumber); // dlo.LoadWith<Ajancy.CarPlateNumber>(cpn => cpn.PlateNumber); // dlo.LoadWith<Ajancy.CarPlateNumber>(cpn => cpn.Car); // dlo.LoadWith<Ajancy.Car>(c => c.FuelCards); // db.LoadOptions = dlo; // Ajancy.Person person = db.Persons.FirstOrDefault<Ajancy.Person>(p => p.PersonID == Public.ToInt(this.ViewState["PersonID"])); // Ajancy.DrivingLicense drivingLicense = person.DrivingLicenses.FirstOrDefault<Ajancy.DrivingLicense>(); // if (drivingLicense == null) // { // drivingLicense = new Ajancy.DrivingLicense(); // } // drivingLicense.DrivingLicenseNo = this.txtDrivingLicenseNo.Text.Trim(); // drivingLicense.ExportDate = this.txtDrivingLicenseDate.GeorgianDate.Value; // drivingLicense.ExportPlace = this.txtDrivingLicensePlace.Text.Trim(); // drivingLicense.Type = Public.ToByte(this.drpDrivingLicenseType.SelectedValue); // Ajancy.DriverCertification driverCertification = person.DriverCertifications.First<Ajancy.DriverCertification>(dc => dc.CertificationType == (byte)Public.AjancyType.TaxiAjancy); // driverCertification.DriverCertificationNo = string.IsNullOrEmpty(this.txtDriverCertificationNo.Text) ? null : this.txtDriverCertificationNo.Text.Trim(); // Ajancy.Car car = driverCertification.DriverCertificationCars.Last<Ajancy.DriverCertificationCar>(dcc => dcc.LockOutDate == null).CarPlateNumber.Car; // car.CarTypeID = Public.ToShort(this.drpCarType.SelectedValue); // car.Model = this.txtCarModel.Text.Trim(); // car.Color = this.txtCarColor.Text.Trim(); // car.EngineNo = this.txtCarEngineNo.Text.Trim(); // car.ChassisNo = this.txtCarChassisNo.Text.Trim(); // car.GASProvider = Public.ToByte(this.drpGASProvider.SelectedValue); // car.FuelType = Public.ToByte(this.drpFuelType.SelectedValue); // Ajancy.FuelCard fuelCard = car.FuelCards.Last<Ajancy.FuelCard>(); // fuelCard.CardType = Public.ToByte(this.drpFuelCardType.SelectedValue); // fuelCard.PAN = this.txtFuelCardPAN.Text.Trim(); // Ajancy.CarPlateNumber carPlateNumber = car.CarPlateNumbers.Last<Ajancy.CarPlateNumber>(); // carPlateNumber.VIN = this.txtCarVIN.Text.Trim(); // carPlateNumber.OwnerPersonID = person.PersonID; // Ajancy.PlateNumber plateNumber = carPlateNumber.PlateNumber; // plateNumber.TwoDigits = this.txtCarPlateNumber_1.Text.Trim(); // plateNumber.Alphabet = this.drpCarPlateNumber.SelectedValue; // plateNumber.ThreeDigits = this.txtCarPlateNumber_2.Text.Trim(); // plateNumber.RegionIdentifier = this.txtCarPlateNumber_3.Text.Trim(); // #region FormerCar // //Ajancy.DriverCertificationCar formerDcc = driverCertification.DriverCertificationCars.SingleOrDefault<Ajancy.DriverCertificationCar>(dcc => dcc.LockOutDate != null && dcc.CarPlateNumber.PlateNumberID == null); // //if (formerDcc != null) // //{ // // if (HasFormerCar()) // Edit // // { // // Ajancy.Car formerCar = formerDcc.CarPlateNumber.Car; // // Ajancy.FuelCard formerFuelCard = formerCar.FuelCards.Last<Ajancy.FuelCard>(); // // if (formerCar != null)// PAN is modified // // { // // if (formerFuelCard.PAN != this.txtFormerCarPAN.Text && db.FuelCards.Any<Ajancy.FuelCard>(fc => fc.PAN == this.txtFormerCarPAN.Text)) // // { // // this.lblMessage.Text = "شماره PAN کارت سوخت خودرو قبلی مربوط به دفترچه صلاحیت برای خودرو دیگری ثبت شده"; // // return; // // } // // formerCar.CarTypeID = Public.ToByte(this.drpFormerCarType.SelectedValue); // // formerCar.Model = this.txtFormerCarModel.Text.Trim(); // // formerCar.EngineNo = this.txtFormerCarEngineNo.Text.Trim(); // // formerCar.ChassisNo = this.txtFormerCarChassisNo.Text.Trim(); // // formerCar.VIN = this.txtFormerCarVIN.Text.Trim(); // // formerCar.FuelType = Public.ToByte(this.drpFormerCarFuelType.SelectedValue); // // formerFuelCard.CardType = Public.ToByte(this.drpFormerCarFuelCardType.SelectedValue); // // formerFuelCard.PAN = this.txtFormerCarPAN.Text.Trim(); // // } // // } // // else // Delete // // { // // db.DriverCertificationCars.DeleteOnSubmit(formerDcc); // // db.CarPlateNumbers.DeleteOnSubmit(formerDcc.CarPlateNumber); // // db.FuelCards.DeleteOnSubmit(formerDcc.CarPlateNumber.Car.FuelCards.Last<Ajancy.FuelCard>()); // // db.Cars.DeleteOnSubmit(formerDcc.CarPlateNumber.Car); // // } // //} // //else if (HasFormerCar()) // Add // //{ // // if (db.FuelCards.Any<Ajancy.FuelCard>(fc => fc.PAN == this.txtFormerCarPAN.Text)) // // { // // this.lblMessage.Text = "شماره PAN کارت سوخت خودرو قبلی مربوط به دفترچه صلاحیت برای خودرو دیگری ثبت شده"; // // return; // // } // // Ajancy.Car formerCar = db.Cars.FirstOrDefault<Ajancy.Car>(c => c.CarTypeID == Public.ToByte(this.drpFormerCarType.SelectedValue) && // // c.EngineNo == this.txtFormerCarEngineNo.Text.Trim() && // // c.ChassisNo == this.txtFormerCarChassisNo.Text.Trim()); // // if (formerCar == null) // // { // // formerCar = new Ajancy.Car(); // // formerCar.CarTypeID = Public.ToByte(this.drpFormerCarType.SelectedValue); // // formerCar.Model = this.txtFormerCarModel.Text.Trim(); // // formerCar.EngineNo = this.txtFormerCarEngineNo.Text.Trim(); // // formerCar.ChassisNo = this.txtFormerCarChassisNo.Text.Trim(); // // formerCar.VIN = this.txtFormerCarVIN.Text.Trim(); // // formerCar.FuelType = Public.ToByte(this.drpFormerCarFuelType.SelectedValue); // // db.Cars.InsertOnSubmit(formerCar); // // } // // Ajancy.FuelCard formerFuelCard = new Ajancy.FuelCard(); // // formerFuelCard.CardType = Public.ToByte(this.drpFormerCarFuelCardType.SelectedValue); // // formerFuelCard.PAN = this.txtFormerCarPAN.Text.Trim(); // // formerFuelCard.SubmitDate = DateTime.Now; // // formerFuelCard.DiscardDate = DateTime.Now; // // formerCar.FuelCards.Add(formerFuelCard); // // driverCertification.DriverCertificationCars.Add(new Ajancy.DriverCertificationCar { CarPlateNumber = new Ajancy.CarPlateNumber { Car = formerCar, Person = person }, LockOutDate = DateTime.Now, SubmitDate = DateTime.Now }); // //} // #endregion // person.FirstName = this.txtFirstName.Text.Trim(); // person.LastName = this.txtLastName.Text.Trim(); // person.Father = this.txtFather.Text.Trim(); // person.BirthCertificateNo = this.txtBirthCertificateNo.Text.Trim(); // person.BirthCertificateSerial = this.txtBirthCertificateSerial.Text.Trim(); // person.BirthCertificateSerie = this.txtBirthCertificateSerie.Text.Trim(); // person.BirthCertificateAlfa = this.drpBirthCertificateAlfa.SelectedValue; // person.Gender = Public.ToByte(this.drpGender.SelectedValue); // person.Marriage = Public.ToByte(this.drpMarriage.SelectedValue); // person.BirthDate = this.txtBirthDate.GeorgianDate.Value; // person.BirthPlace = this.txtBirthPlace.Text.Trim(); // person.BirthCertificatePlace = this.txtBirthCertificatePlace.Text.Trim(); // person.FamilyMembersCount = this.txtFamilyMembersCount.Text.Trim(); // person.Education = Public.ToByte(this.drpEducation.SelectedValue); // person.MilitaryService = Public.ToByte(this.drpMilitaryService.SelectedValue); // person.Religion = Public.ToByte(this.drpReligion.SelectedValue); // person.Subreligion = this.txtSubreligion.Text.Trim(); // person.JobStatus = Public.ToByte(this.drpJobStatus.SelectedValue); // person.Phone = this.txtPhone.Text.Trim(); // person.Mobile = this.txtMobile.Text.Trim(); // person.PostalCode = this.txtPostalCode.Text.Trim(); // person.Address = this.txtAddress.Text.Trim(); // person.FormerJob = this.txtFormerJob.Text.Trim(); // person.FormerJobType = Public.ToByte(this.drpFormerJobType.SelectedValue); // // Sets the owner of the car // Ajancy.Person carOwner = null; // if (!string.IsNullOrEmpty(this.txtOwnerName.Text) && !string.IsNullOrEmpty(this.txtOwnerFamily.Text) && !string.IsNullOrEmpty(this.txtOwnerNationalCode.Text) && !this.txtOwnerNationalCode.Text.Equals(person.NationalCode)) // { // carOwner = db.Persons.FirstOrDefault<Ajancy.Person>(p => p.NationalCode == this.txtOwnerNationalCode.Text.Trim()); // if (carOwner == null) // { // carOwner = new Ajancy.Person { NationalCode = this.txtOwnerNationalCode.Text.Trim(), FirstName = this.txtOwnerName.Text.Trim(), LastName = this.txtOwnerFamily.Text.Trim(), SubmitDate = DateTime.Now, TraceCode = Public.GetTraceKey() }; // Ajancy.User userOwner = new Ajancy.User(); // userOwner.UserName = this.txtOwnerNationalCode.Text.Trim(); // userOwner.ProvinceID = person.User.ProvinceID; // userOwner.CityID = person.User.CityID; // userOwner.SubmitDate = DateTime.Now; // userOwner.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now }); // carOwner.User = userOwner; // db.Persons.InsertOnSubmit(carOwner); // } // else // { // if (!carOwner.User.UsersInRoles.Any<Ajancy.UsersInRole>(ur => ur.RoleID == (short)Public.Role.CarOwner)) // { // carOwner.User.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now }); // } // } // carOwner.CarPlateNumbers.Add(carPlateNumber); // person.CarPlateNumbers.Remove(carPlateNumber); // } // try // { // db.SubmitChanges(); // Response.Redirect("~/Message.aspx?mode=7"); // } // catch (Exception ex) // { // if (ex.Message.Contains("DrivingLicenseNo")) // { // this.lblMessage.Text = "شماره گواهینامه رانندگی تکراری میباشد"; // } // else // { // throw ex; // } // } // } //} private void SetPerson(Ajancy.Person person) { if (person == null) { this.ViewState["PersonID"] = null; this.txtFirstName.Text = null; this.txtLastName.Text = null; this.txtFather.Text = null; this.txtBirthCertificateNo.Text = null; this.txtBirthCertificateSerial.Text = null; this.txtBirthCertificateSerie.Text = null; this.drpBirthCertificateAlfa.SelectedIndex = 0; this.drpGender.SelectedIndex = 0; this.txtBirthDate.Text = null; this.txtBirthPlace.Text = null; this.txtBirthCertificatePlace.Text = null; this.drpMarriage.SelectedIndex = 0; this.txtFamilyMembersCount.Text = null; this.drpEducation.SelectedIndex = 0; this.drpMilitaryService.SelectedIndex = 0; this.drpReligion.SelectedIndex = 0; this.txtSubreligion.Text = null; this.drpJobStatus.SelectedIndex = 0; this.txtPhone.Text = null; this.txtMobile.Text = null; this.txtPostalCode.Text = null; this.txtAddress.Text = null; SetDrivingLicense(null); SetCarOwner(null); SetCar(null); SetFuelCard(null); //SetFormerCar(null); } else { this.ViewState["PersonID"] = person.PersonID; this.txtFirstName.Text = person.FirstName; this.txtLastName.Text = person.LastName; this.txtFather.Text = person.Father; this.txtNationalCode.Text = person.NationalCode; this.txtBirthCertificateNo.Text = person.BirthCertificateNo; this.txtBirthCertificateSerial.Text = person.BirthCertificateSerial; this.txtBirthCertificateSerie.Text = person.BirthCertificateSerie; this.drpBirthCertificateAlfa.SelectedValue = person.BirthCertificateAlfa; this.drpGender.SelectedValue = person.Gender.GetValueOrDefault().ToString(); this.txtBirthDate.SetDate(person.BirthDate); this.txtBirthPlace.Text = person.BirthPlace; this.txtBirthCertificatePlace.Text = person.BirthCertificatePlace; this.drpMarriage.SelectedValue = person.Marriage.GetValueOrDefault().ToString(); this.txtFamilyMembersCount.Text = person.FamilyMembersCount; this.drpEducation.SelectedValue = person.Education.GetValueOrDefault().ToString(); this.drpMilitaryService.SelectedValue = person.MilitaryService.GetValueOrDefault().ToString(); this.drpReligion.SelectedValue = person.Religion.GetValueOrDefault().ToString(); this.txtSubreligion.Text = person.Subreligion; this.drpJobStatus.SelectedValue = person.JobStatus.GetValueOrDefault().ToString(); this.txtPhone.Text = person.Phone; this.txtMobile.Text = person.Mobile; this.txtPostalCode.Text = person.PostalCode; this.txtAddress.Text = person.Address; //this.drpFormerJobType.SelectedValue = person.FormerJobType.GetValueOrDefault().ToString(); //this.txtFormerJob.Text = person.FormerJob; if (person.DriverCertifications.Count > 0) { Ajancy.DriverCertification driverCertification = person.DriverCertifications.SingleOrDefault<Ajancy.DriverCertification>(dc => dc.CertificationType == (byte)Public.AjancyType.TaxiAjancy); Ajancy.DriverCertificationCar driverCertificationCar = driverCertification.DriverCertificationCars.Last<Ajancy.DriverCertificationCar>(); SetDrivingLicense(person.DrivingLicenses.LastOrDefault<Ajancy.DrivingLicense>()); SetCarOwner(driverCertificationCar.CarPlateNumber.Person); SetCar(driverCertificationCar.CarPlateNumber.Car); SetFuelCard(driverCertificationCar.CarPlateNumber.Car.FuelCards.Last<Ajancy.FuelCard>()); this.txtDriverCertificationNo.Text = driverCertification.DriverCertificationNo; this.drpDriverCertificationNo.SelectedIndex = string.IsNullOrEmpty(driverCertification.DriverCertificationNo) ? 1 : 0; //Ajancy.DriverCertificationCar formerDcc = driverCertification.DriverCertificationCars.SingleOrDefault<Ajancy.DriverCertificationCar>(dcc => dcc.LockOutDate != null && dcc.CarPlateNumber.PlateNumberID == null); //if (formerDcc != null) //{ // SetFormerCar(formerDcc.CarPlateNumber.Car); //} } } }
private void SetPlateNumber(Ajancy.PlateNumber plateNumber) { if (plateNumber != null) { this.txtCarPlateNumber_1.Text = plateNumber.TwoDigits; this.drpCarPlateNumber.SelectedValue = plateNumber.Alphabet; this.txtCarPlateNumber_2.Text = plateNumber.ThreeDigits; this.txtCarPlateNumber_3.Text = plateNumber.RegionIdentifier; } else { this.txtCarPlateNumber_1.Text = null; this.drpCarPlateNumber.SelectedIndex = 0; this.txtCarPlateNumber_2.Text = null; this.txtCarPlateNumber_3.Text = null; } }
private void SetCar(Ajancy.Car car) { if (car == null) { this.txtCarVIN.Text = null; this.txtCarModel.Text = null; this.drpCarType.SelectedIndex = 0; this.drpFuelType.SelectedIndex = 0; SetPlateNumber(null); } else { this.txtCarVIN.Text = car.VIN; this.txtCarModel.Text = car.Model; this.drpCarType.SelectedValue = car.CarTypeID.ToString(); this.drpFuelType.SelectedValue = car.FuelType.ToString(); SetPlateNumber(car.CarPlateNumbers.Last<Ajancy.CarPlateNumber>().ZonePlateNumber); } }
private void SetFuelCard(Ajancy.FuelCard fuelCard) { if (fuelCard == null) { this.txtFuelCardPAN.Text = null; } else { this.txtFuelCardPAN.Text = fuelCard.PAN; } }
private void SetPerson(Ajancy.Person person) { if (person == null) { this.ViewState["PersonID"] = null; this.txtFirstName.Text = null; this.txtLastName.Text = null; SetCarOwner(null); SetCar(null); SetFuelCard(null); } else { this.ViewState["PersonID"] = person.PersonID; this.txtFirstName.Text = person.FirstName; this.txtLastName.Text = person.LastName; this.txtNationalCode.Text = person.NationalCode; if (person.DriverCertifications.Count > 0) { Ajancy.DriverCertification driverCertification = person.DriverCertifications.SingleOrDefault<Ajancy.DriverCertification>(dc => dc.CertificationType == (byte)Public.AjancyType.TaxiAjancy); if (driverCertification != null) { if (Request.QueryString["nc"] == null) // Add mode { if (Public.ActiveUserRole.RoleID == (short)Public.Role.ProvinceManager) // Is ProvinceManager { if (person.User.ProvinceID != Public.ActiveUserRole.User.ProvinceID) { DisposeContext(); Response.Redirect("~/Message.aspx?mode=15"); // This is a driver of an other province } else if (person.User.CityID.Value.ToString() != this.drpCity.SelectedValue) { this.drpCity.SelectedValue = person.User.CityID.Value.ToString(); LoadAjancies(true); } } else if (Public.ActiveUserRole.RoleID == (short)Public.Role.CityManager && person.User.CityID != Public.ActiveUserRole.User.CityID) { DisposeContext(); Response.Redirect("~/Message.aspx?mode=13"); // This is a driver of an other city } } else // Edit mode { if (Public.ActiveUserRole.RoleID == (short)Public.Role.ProvinceManager) // Is ProvinceManager { this.drpCity.SelectedValue = person.User.CityID.Value.ToString(); } LoadAjancies(true); } Ajancy.DriverCertificationCar driverCertificationCar = driverCertification.DriverCertificationCars.Last<Ajancy.DriverCertificationCar>(dcc => dcc.LockOutDate == null); try { this.drpAjancies.SelectedValue = driverCertificationCar.AjancyDrivers.Last<Ajancy.AjancyDriver>(jd => jd.LockOutDate == null).AjancyID.ToString(); } catch { } if (driverCertificationCar.CarPlateNumber.PlateNumberID.HasValue) { DisposeContext(); Response.Redirect("~/Message.aspx?mode=30"); // This driver's current platenumber is of type Iran } SetCarOwner(driverCertificationCar.CarPlateNumber.Person); SetCar(driverCertificationCar.CarPlateNumber.Car); SetFuelCard(driverCertificationCar.CarPlateNumber.Car.FuelCards.Last<Ajancy.FuelCard>()); } } } }
private void SetPerson(Ajancy.Person person) { if (person == null) { this.txtFirstName.Text = null; this.txtLastName.Text = null; this.txtFather.Text = null; this.txtBirthCertificateNo.Text = null; this.txtBirthCertificateSerial.Text = null; this.txtBirthCertificateSerie.Text = null; this.drpBirthCertificateAlfa.SelectedIndex = 0; this.drpGender.SelectedIndex = 0; this.txtBirthDate.Text = null; this.txtBirthPlace.Text = null; this.txtBirthCertificatePlace.Text = null; this.drpMarriage.SelectedIndex = 0; this.txtFamilyMembersCount.Text = null; this.drpEducation.SelectedIndex = 0; this.drpMilitaryService.SelectedIndex = 0; this.drpReligion.SelectedIndex = 0; this.txtSubreligion.Text = null; this.drpJobStatus.SelectedIndex = 0; this.txtPhone.Text = null; this.txtMobile.Text = null; this.txtPostalCode.Text = null; this.txtAddress.Text = null; } else { this.txtFirstName.Text = person.FirstName; this.txtLastName.Text = person.LastName; this.txtFather.Text = person.Father; this.txtNationalCode.Text = person.NationalCode; this.txtBirthCertificateNo.Text = person.BirthCertificateNo; this.txtBirthCertificateSerial.Text = person.BirthCertificateSerial; this.txtBirthCertificateSerie.Text = person.BirthCertificateSerie; this.drpBirthCertificateAlfa.SelectedValue = person.BirthCertificateAlfa; this.drpGender.SelectedValue = person.Gender.GetValueOrDefault().ToString(); this.txtBirthDate.SetDate(person.BirthDate); this.txtBirthPlace.Text = person.BirthPlace; this.txtBirthCertificatePlace.Text = person.BirthCertificatePlace; this.drpMarriage.SelectedValue = person.Marriage.GetValueOrDefault().ToString(); this.txtFamilyMembersCount.Text = person.FamilyMembersCount; this.drpEducation.SelectedValue = person.Education.GetValueOrDefault().ToString(); this.drpMilitaryService.SelectedValue = person.MilitaryService.GetValueOrDefault().ToString(); this.drpReligion.SelectedValue = person.Religion.GetValueOrDefault().ToString(); this.txtSubreligion.Text = person.Subreligion; this.drpJobStatus.SelectedValue = person.JobStatus.GetValueOrDefault().ToString(); this.txtPhone.Text = person.Phone; this.txtMobile.Text = person.Mobile; this.txtPostalCode.Text = person.PostalCode; this.txtAddress.Text = person.Address; if (person.DriverCertifications.Count == 1) { this.txtDriverCertificationNo.Text = person.DriverCertifications[0].DriverCertificationNo; SetDrivingLicense(person.DrivingLicenses.LastOrDefault<Ajancy.DrivingLicense>()); Ajancy.CarPlateNumber cpn = person.DriverCertifications.LastOrDefault<Ajancy.DriverCertification>().DriverCertificationCars.LastOrDefault<Ajancy.DriverCertificationCar>().CarPlateNumber; SetCar(cpn.Car); SetFuelCard(person.DriverCertifications.LastOrDefault<Ajancy.DriverCertification>().DriverCertificationCars.LastOrDefault<Ajancy.DriverCertificationCar>().CarPlateNumber.Car.FuelCards.Last<Ajancy.FuelCard>()); } } }
private void SetInsurance(Ajancy.Insurance Insurance) { if (Insurance == null) { this.txtInsuranceNo.Text = null; this.txtBranchNo.Text = null; } else { this.txtInsuranceNo.Text = Insurance.InsuranceNo; this.txtBranchNo.Text = Insurance.BranchNo; } }