当前位置: 首页>>代码示例>>C#>>正文


C# Kimia_Ajancy.SubmitChanges方法代码示例

本文整理汇总了C#中Ajancy.Kimia_Ajancy.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Kimia_Ajancy.SubmitChanges方法的具体用法?C# Kimia_Ajancy.SubmitChanges怎么用?C# Kimia_Ajancy.SubmitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ajancy.Kimia_Ajancy的用法示例。


在下文中一共展示了Kimia_Ajancy.SubmitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: fluDocument_UploadedComplete

    protected void fluDocument_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        if (this.fluDocument.HasFile)
        {
            if (this.fluDocument.PostedFile.ContentType.Equals("image/pjpeg") || this.fluDocument.PostedFile.ContentType.Equals("image/x-png"))
            {
                byte[] fileByte = this.fluDocument.FileBytes;
                Binary binaryObj = new Binary(fileByte);
                Ajancy.Kimia_Ajancy db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
                Ajancy.Doument doc = db.Douments.FirstOrDefault<Ajancy.Doument>(d => d.PersonID == Public.ActiveUserRole.User.PersonID && d.DocumentType == 1);

                if (doc == null)
                {
                    doc = new Ajancy.Doument
                                {
                                    DocumentType = Public.ToByte(this.drpType.SelectedValue),
                                    PersonID = Public.ActiveUserRole.User.PersonID,
                                    Picture = binaryObj,
                                    SubmitDate = DateTime.Now
                                };
                    db.Douments.InsertOnSubmit(doc);
                }
                else
                {
                    doc.Picture = binaryObj;
                }
                db.SubmitChanges();
                db.Dispose();
            }
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:31,代码来源:UploadDocument.aspx.cs

示例2: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int commentId = 0;
         if (Request.QueryString["mode"] != null)
         {
             switch (Request.QueryString["mode"])
             {
                 case "0": // Delete mode
                     if (int.TryParse(Request.QueryString["id"], out commentId))
                     {
                         db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
                         db.Comments.DeleteOnSubmit(db.Comments.First<Ajancy.Comment>(c => c.CommentID == commentId));
                         db.SubmitChanges();
                         DisposeContext();
                         Response.Clear();
                         Response.Write("1");
                         Response.End();
                     }
                     break;
             }
         }
     }
 }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:25,代码来源:HandleComments.aspx.cs

示例3: btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.Page.IsValid && this.ViewState["UserID"] != null)
        {
            byte selectedRoleId = byte.Parse(this.drpRoles.SelectedValue);
            ListItem item = null;
            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
            Ajancy.User user = db.Users.First<Ajancy.User>(u => u.UserID == Public.ToInt(this.ViewState["UserID"]));
            Ajancy.UsersInRole userRole = new Ajancy.UsersInRole { RoleID = selectedRoleId, MembershipDate = DateTime.Now }; ;
            user.UsersInRoles.Add(userRole);

            switch ((Public.Role)selectedRoleId)
            {
                case Public.Role.AjancyManager:
                case Public.Role.AjancySupervisor:
                case Public.Role.AjancySecretary:
                case Public.Role.AjancyPartner:
                    Ajancy.AjancyPartner partner = new Ajancy.AjancyPartner { SubmitDate = DateTime.Now };
                    userRole.AjancyPartners.Add(partner);
                    db.SubmitChanges();
                    item = new ListItem(string.Format("{0} {1}", Public.GetRoleName(userRole.RoleID), "---"), string.Format("{0}|{1}", userRole.UserRoleID, partner.AjancyPartnerID));
                    break;

                case Public.Role.ProvinceManager:
                case Public.Role.AcademyProvince:
                    db.SubmitChanges();
                    item = new ListItem(string.Format("{0} {1}", Public.GetRoleName(selectedRoleId), user.City.Province.Name), string.Format("{0}|0", userRole.UserRoleID));
                    break;

                case Public.Role.CityManager:
                case Public.Role.AcademyCity:
                    db.SubmitChanges();
                    item = new ListItem(string.Format("{0} {1}", Public.GetRoleName(selectedRoleId), user.City.Name), string.Format("{0}|0", userRole.UserRoleID));
                    break;

                default:
                    db.SubmitChanges();
                    item = new ListItem(Public.GetRoleName(selectedRoleId), string.Format("{0}|0", userRole.UserRoleID));
                    break;
            }

            item.Selected = true;
            this.lstRoles.Items.Add(item);
            this.drpRoles.Items.Remove(this.drpRoles.SelectedItem);
            this.lblMessage.Text = "ثبت سمت انجام گردید";
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:47,代码来源:UserRoles.aspx.cs

示例4: btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e)
    {
        int personId = 0;
        if (this.Page.IsValid && int.TryParse(TamperProofString.QueryStringDecode(Request.QueryString["id"]), out personId))
        {
            DataLoadOptions dlo = new DataLoadOptions();
            dlo.LoadWith<Ajancy.Person>(p => p.User);
            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
            db.LoadOptions = dlo;
            Ajancy.Person person = db.Persons.First<Ajancy.Person>(p => p.PersonID == personId);
            if (person.NationalCode != this.txtNationalCode.Text.Trim()) // Nationalcode is changed
            {
                person.NationalCode = this.txtNationalCode.Text;
                person.User.UserName = this.txtNationalCode.Text;
            }

            person.User.ProvinceID = Public.ToByte(this.drpProvince.SelectedValue);
            person.User.CityID = Public.ToShort(this.drpCity.SelectedValue);
            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;
            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();

            try
            {
                db.SubmitChanges();
                DisposeContext();
                Response.Redirect("~/Message.aspx?mode=17");
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    this.lblMessage.Text = "کد ملی تکراری میباشد";
                }
            }
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:56,代码来源:Person.aspx.cs

示例5: btnChangePassword_Click

 protected void btnChangePassword_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
         db.Users.First<Ajancy.User>(u => u.UserID == Public.ToInt(this.ViewState["UserID"])).PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassword.Text, "SHA1");
         db.SubmitChanges();
         this.btnBack_Click(sender, e);
     }
 }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:10,代码来源:UsersList.aspx.cs

示例6: lstRoles_SelectedIndexChanged

 protected void lstRoles_SelectedIndexChanged(object sender, EventArgs e)
 {
     db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
     foreach (ListItem item in this.lstRoles.Items)
     {
         string[] roleParts = item.Value.Split('|');
         if (roleParts[1] == "0")
         {
             Ajancy.UsersInRole userRole = db.UsersInRoles.First<Ajancy.UsersInRole>(ur => ur.UserRoleID == Public.ToInt(roleParts[0]));
             if (item.Selected && userRole.LockOutDate.HasValue) // unlock this role
             {
                 userRole.LockOutDate = null;
                 db.SubmitChanges();
                 break;
             }
             else if (!item.Selected && !userRole.LockOutDate.HasValue) // lock this role
             {
                 userRole.LockOutDate = DateTime.Now;
                 db.SubmitChanges();
                 break;
             }
         }
         else if (roleParts.Length == 2) // Ajancy partners
         {
             Ajancy.AjancyPartner partner = db.AjancyPartners.First<Ajancy.AjancyPartner>(jp => jp.AjancyPartnerID == Public.ToInt(roleParts[1]));
             if (item.Selected && partner.LockOutDate.HasValue) // unlock this role
             {
                 partner.LockOutDate = null;
                 db.SubmitChanges();
                 break;
             }
             else if (!item.Selected && !partner.LockOutDate.HasValue) // lock this role
             {
                 partner.LockOutDate = DateTime.Now;
                 db.SubmitChanges();
                 break;
             }
         }
     }
 }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:40,代码来源:UserRoles.aspx.cs

示例7: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int fcsId;
            if (int.TryParse(Request.QueryString["fcsId"], out fcsId))
            {
                db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
                db.FuelCardSubstitutions.DeleteOnSubmit(db.FuelCardSubstitutions.First<Ajancy.FuelCardSubstitution>(fcs => fcs.FuelCardSubstituteID == fcsId));
                db.SubmitChanges();
                DisposeContext();
                Response.Clear();
                Response.Write("1");
                Response.End();
            }

            Ajancy.User user = Public.ActiveUserRole.User;
            this.drpProvince.SelectedValue = user.ProvinceID.ToString();
            this.drpProvince_SelectedIndexChanged(sender, e);
            this.drpCity.SelectedValue = user.CityID.ToString();

            switch ((Public.Role)Public.ActiveUserRole.RoleID)
            {
                case Public.Role.Admin:
                    this.drpProvince.Enabled = true;
                    this.drpCity.Enabled = true;
                    this.drpAjancyType.Enabled = true;
                    break;

                case Public.Role.CityManager:
                    this.drpAjancyType.SelectedIndex = 0;
                    break;

                case Public.Role.ProvinceManager:
                    this.drpCity.Enabled = true;
                    this.drpAjancyType.SelectedIndex = 0;
                    break;

                case Public.Role.AcademyCity:
                    this.drpAjancyType.SelectedIndex = 2;
                    break;

                case Public.Role.AcademyProvince:
                    this.drpCity.Enabled = true;
                    this.drpAjancyType.SelectedIndex = 2;
                    break;
            }
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:49,代码来源:FCDiscardsRep.aspx.cs

示例8: btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.Page.IsValid)
        {
            int carId = Public.ToInt(this.drpCars.SelectedValue);
            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
            db.FuelCards.First<Ajancy.FuelCard>(fc => fc.CarID == carId && fc.DiscardDate == null).DiscardDate = DateTime.Now;
            db.FuelCards.InsertOnSubmit(new Ajancy.FuelCard
            {
                CarID = carId
                                 ,
                CardType = Public.ToByte(this.drpFuelCardType.SelectedValue)
                                 ,
                PAN = this.txtFuelCardPAN.Text.Trim()
                                 ,
                SubmitDate = DateTime.Now
            });

            try
            {
                db.SubmitChanges();
                DisposeContext();
                this.drpCars_SelectedIndexChanged(sender, e);
                this.lblMessage.Text = Public.SAVEMESSAGE;
                this.drpFuelCardType.SelectedIndex = 0;
                this.txtFuelCardPAN.Text = null;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("UNIQUE KEY"))
                {
                    this.lblMessage.Text = "شماره PAN کارت سوخت قبلا برای خودرو دیگری ثبت شده";
                }
                else
                {
                    throw ex;
                }
            }
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:40,代码来源:AddFuelCard.aspx.cs

示例9: btnSave_Click

 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         Ajancy.Kimia_Ajancy db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
         Ajancy.User user = db.Users.FirstOrDefault<Ajancy.User>(u => u.UserName == HttpContext.Current.User.Identity.Name && u.PassWord == FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtOldPassword.Text, "SHA1"));
         if (user != null)
         {
             user.PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtNewPassword.Text, "SHA1");
             db.SubmitChanges();
             db.Dispose();
             this.lblMessage.Text = "ویرایش گذرواژه انجام گردید";
         }
         else
         {
             this.lblMessage.Text = "گذرواژه نادرست میباشد";
         }
     }
     this.txtOldPassword.Text = null;
     this.txtNewPassword.Text = null;
     this.txtRePassword.Text = null;
 }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:22,代码来源:EditPassword.aspx.cs

示例10: btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid && this.ViewState["AjancyDriverID"] != null)
        {
            string[] vals = this.ViewState["AjancyDriverID"].ToString().Split('|');
            if (vals[1] == this.drpAjancies.SelectedValue) // No new ajancy is selected
            {
                return;
            }

            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
            Ajancy.AjancyDriver ajancyDriver = db.AjancyDrivers.First<Ajancy.AjancyDriver>(jd => jd.AjancyDriverID == Public.ToInt(vals[0]));
            ajancyDriver.LockOutDate = DateTime.Now;
            db.AjancyDrivers.InsertOnSubmit(new Ajancy.AjancyDriver { AjancyID = Public.ToInt(this.drpAjancies.SelectedValue), DriverCertificationCarID = ajancyDriver.DriverCertificationCarID, MembershipDate = DateTime.Now });
            db.SubmitChanges();
            this.lblMessage.Text = Public.SAVEMESSAGE;
            this.ViewState["AjancyDriverID"] = null;
            this.txtNationalCode.Text = null;
            this.drpAjancies.Items.Clear();
            this.drpAjancies.Enabled = false;
            this.btnSave.Enabled = false;
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:23,代码来源:TransferDriver.aspx.cs

示例11: btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            Ajancy.Comment comment = new Ajancy.Comment();
            comment.DriverFirstName = this.txtDriverFirstName.Text;
            comment.DriverLastName = this.txtDriverLastName.Text;
            comment.FirstName = this.txtFirstName.Text;
            comment.LastName = this.txtLastName.Text;
            comment.Phone = this.txtPhone.Text;
            comment.Email = this.txtEmail.Text;
            comment.AjancyID = Public.ToInt(this.drpAjancies.SelectedValue);
            comment.Subject = Public.ToByte(this.drpSubject.SelectedValue);
            comment.ProblemDate = new DateTime(this.txtProblemDate.GeorgianDate.Value.Year, this.txtProblemDate.GeorgianDate.Value.Month, this.txtProblemDate.GeorgianDate.Value.Day, this.txtTime.Time.Hours, this.txtTime.Time.Minutes, 0);
            comment.CommentText = this.txtComment.Text;
            comment.SubmitDate = DateTime.Now;
            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);

            if (!string.IsNullOrEmpty(this.txtCarPlateNumber_1.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_2.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_3.Text))
            {
                Ajancy.PlateNumber plateNumber = db.PlateNumbers.FirstOrDefault<Ajancy.PlateNumber>(pn => pn.TwoDigits == this.txtCarPlateNumber_1.Text &&
                                                                                                                                                 pn.Alphabet == this.drpCarPlateNumber.SelectedValue &&
                                                                                                                                                 pn.ThreeDigits == this.txtCarPlateNumber_3.Text &&
                                                                                                                                                 pn.RegionIdentifier == this.txtCarPlateNumber_3.Text);
                if (plateNumber == null)
                {
                    this.lblMessage.Text = "کابر گرامی شماره پلاک مورد نظر شما متعلق به رانندگان این اتحادیه نمیباشد در صورت اطمینان از درست بودن شماره پلاک در قسمت توضیحات آنرا بنویسید";
                    return;
                }
                comment.PlateNumberID = plateNumber.PlateNumberID;
            }

            db.Comments.InsertOnSubmit(comment);
            db.SubmitChanges();
            Response.Redirect("~/Default.aspx");
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:37,代码来源:Comment.aspx.cs

示例12: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
            if (Request.QueryString["mode"] != null)
            {
                int ajancyDriverId = 0;
                switch (Request.QueryString["mode"])
                {
                    case "0": // Complaint
                        if (int.TryParse(Request.QueryString["jdId"], out ajancyDriverId) && Request.QueryString["text"] != null)
                        {
                            db.AjancyComplaints.InsertOnSubmit(new Ajancy.AjancyComplaint { AjancyDriverID = ajancyDriverId, RoleID = Public.ActiveUserRole.RoleID, Comment = Request.QueryString["text"].Length > 200 ? Request.QueryString["text"].Substring(0, 200) : Request.QueryString["text"], SubmitDate = DateTime.Now });
                            db.SubmitChanges();
                            DisposeContext();
                            Response.Clear();
                            Response.Write("1");
                            Response.End();
                        }
                        break;

                    case "1": // CNG
                        if (int.TryParse(Request.QueryString["jdId"], out ajancyDriverId) && Request.QueryString["text"] != null)
                        {
                            db.CNG_ConsumptionRequests.InsertOnSubmit(new Ajancy.CNG_ConsumptionRequest { AjancyDriverID = ajancyDriverId, Comment = string.IsNullOrEmpty(Request.QueryString["text"]) ? null : Request.QueryString["text"].Length > 200 ? Request.QueryString["text"].Substring(0, 200) : Request.QueryString["text"], SubmitDate = DateTime.Now });
                            db.SubmitChanges();
                            DisposeContext();
                            Response.Clear();
                            Response.Write("1");
                            Response.End();
                        }
                        break;

                    //case "2": // ajancyCardType
                    //    if (int.TryParse(Request.QueryString["jdId"], out ajancyDriverId) && Request.QueryString["text"] != null)
                    //    {
                    //        db.AjancyFuelCardTypeRequests.InsertOnSubmit(new Ajancy.AjancyFuelCardTypeRequest { AjancyDriverID = ajancyDriverId, Comment = string.IsNullOrEmpty(Request.QueryString["text"]) ? null : Request.QueryString["text"].Length > 200 ? Request.QueryString["text"].Substring(0, 200) : Request.QueryString["text"], SubmitDate = DateTime.Now });
                    //        db.SubmitChanges();
                    //        Response.Clear();
                    //        Response.Write("1");
                    //        Response.End();
                    //    }
                    //    break;

                    case "3": // Insurance
                        if (int.TryParse(Request.QueryString["jdId"], out ajancyDriverId) && Request.QueryString["text"] != null)
                        {
                            db.DriverInsuranceRequests.InsertOnSubmit(new Ajancy.DriverInsuranceRequest { AjancyDriverID = ajancyDriverId, Comment = string.IsNullOrEmpty(Request.QueryString["text"]) ? null : Request.QueryString["text"].Length > 200 ? Request.QueryString["text"].Substring(0, 200) : Request.QueryString["text"], SubmitDate = DateTime.Now });
                            db.SubmitChanges();
                            DisposeContext();
                            Response.Clear();
                            Response.Write("1");
                            Response.End();
                        }
                        break;

                    case "4": // End Membership
                        if (int.TryParse(Request.QueryString["jdId"], out ajancyDriverId) && Request.QueryString["text"] != null)
                        {
                            db.DriverEndMembershipRequests.InsertOnSubmit(new Ajancy.DriverEndMembershipRequest { AjancyDriverID = ajancyDriverId, RoleID = Public.ActiveUserRole.RoleID, Comment = Request.QueryString["text"].Length > 200 ? Request.QueryString["text"].Substring(0, 200) : Request.QueryString["text"], SubmitDate = DateTime.Now, Confirmed = false });
                            db.SubmitChanges();
                            DisposeContext();
                            Response.Clear();
                            Response.Write("1");
                            Response.End();
                        }
                        break;
                }
            }
            this.drpCarType.DataSource = db.CarTypes;
            this.drpCarType.DataBind();
            this.drpCarType.Items.Insert(0, "- همه موارد -");
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:75,代码来源:DriversList.aspx.cs

示例13: btnSave_Click


//.........这里部分代码省略.........
                }

                switch ((Public.Role)Public.ActiveUserRole.RoleID)
                {
                    case Public.Role.ProvinceManager:
                        person.User.CityID = Public.ToShort(this.drpCity.SelectedValue);
                        break;

                    case Public.Role.Admin:
                        person.User.ProvinceID = Public.ToByte(this.drpProvince.SelectedValue);
                        person.User.CityID = Public.ToShort(this.drpCity.SelectedValue);
                        break;
                }
            }

            // --------------- setting values

            person.FirstName = this.txtFirstName.Text.Trim();
            person.LastName = this.txtLastName.Text.Trim();

            plateNumber.CityID = Public.ToShort(this.drpCarPlateNumberCity.SelectedValue);
            plateNumber.Number = this.txtCarPlateNumber_5.Text.Trim();

            car.CarTypeID = Public.ToShort(this.drpCarType.SelectedValue);
            car.FuelType = Public.ToByte(this.drpFuelType.SelectedValue);
            car.Model = this.txtCarModel.Text;

            fuelCard.CardType = (byte)Public.FuelCardType.Ajancy;
            fuelCard.PAN = this.txtFuelCardPAN.Text.Trim();

            car.VIN = this.txtCarVIN.Text.Trim().ToUpper();

            // Sets the owner of the car
            Ajancy.Person ownerPer = 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))
            {
                ownerPer = db.Persons.FirstOrDefault<Ajancy.Person>(p => p.NationalCode == this.txtOwnerNationalCode.Text.Trim());
                if (ownerPer == null)
                {
                    ownerPer = new Ajancy.Person { NationalCode = this.txtOwnerNationalCode.Text.Trim(), SubmitDate = DateTime.Now };
                    Ajancy.User ownerUser = new Ajancy.User
                    {
                        UserName = this.txtOwnerNationalCode.Text.Trim()
                        ,
                        ProvinceID = person.User.ProvinceID
                        ,
                        CityID = person.User.CityID
                        ,
                        SubmitDate = DateTime.Now
                    };
                    ownerUser.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now });
                    ownerPer.User = ownerUser;
                    db.Persons.InsertOnSubmit(ownerPer);
                }
                else if (!ownerPer.User.UsersInRoles.Any<Ajancy.UsersInRole>(ur => ur.RoleID == (short)Public.Role.CarOwner))
                {
                    ownerPer.User.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now });
                }

                ownerPer.FirstName = this.txtOwnerName.Text.Trim();
                ownerPer.LastName = this.txtOwnerFamily.Text.Trim();
                person.CarPlateNumbers.Remove(carPlateNumber);
                ownerPer.CarPlateNumbers.Add(carPlateNumber);
            }
            else if (carPlateNumber.OwnerPersonID > 0 && carPlateNumber.OwnerPersonID != person.PersonID) // Set the driver as owner again
            {
                carPlateNumber.Person = person;
            }

            #endregion

            if (this.ViewState["Mode"] == null) // Add mode
            {
                Ajancy.FuelCardSubstitution formerReq = null;
                if (fuelCard.FuelCardID > 0)
                {
                    formerReq = db.FuelCardSubstitutions.FirstOrDefault<Ajancy.FuelCardSubstitution>(fcs => (fcs.AjancyTypeFuelCardID == fuelCard.FuelCardID || fcs.PersonalTypeFuelCardID.GetValueOrDefault() == fuelCard.FuelCardID));
                }

                if (formerReq == null)
                {
                    db.FuelCardSubstitutions.InsertOnSubmit(new Ajancy.FuelCardSubstitution
                    {
                        FuelCard = fuelCard,
                        UserInRoleID = (short)Public.ActiveUserRole.UserRoleID,
                        SubmitDate = DateTime.Now
                    });
                }
                else
                {
                    this.lblMessage.Text = "برای کارت سوخت مورد نظر قبلا درخواست ابطال یا جایگزین ثبت شده است";
                    return;
                }
            }

            db.SubmitChanges();
            DisposeContext();
            Response.Redirect("~/Message.aspx?mode=10");
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:101,代码来源:FCDiscard.aspx.cs

示例14: btnSave_Click


//.........这里部分代码省略.........
                            carPlateNumber_2.Person = person_2;
                        }
                    }
                }

                if (ajancyTypeOwner && this.txtNationalCode_2.Text == this.txtOwnerNationalCode.Text) // Cross \
                {
                    if (!person_2.User.UsersInRoles.Any<Ajancy.UsersInRole>(ur => ur.RoleID == (short)Public.Role.CarOwner))
                    {
                        person_2.User.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now });
                    }
                    person_2.CarPlateNumbers.Add(carPlateNumber);
                }
                else
                {
                    if (ajancyTypeOwner)
                    {
                        ownerPer = db.Persons.FirstOrDefault<Ajancy.Person>(p => p.NationalCode == this.txtOwnerNationalCode.Text.Trim());
                        if (ownerPer == null)
                        {
                            ownerPer = new Ajancy.Person { NationalCode = this.txtOwnerNationalCode.Text.Trim(), SubmitDate = DateTime.Now };
                            Ajancy.User ownerUser = new Ajancy.User
                            {
                                UserName = this.txtOwnerNationalCode.Text.Trim()
                                ,
                                ProvinceID = person.User.ProvinceID
                                ,
                                CityID = person.User.CityID
                                ,
                                SubmitDate = DateTime.Now
                            };
                            ownerUser.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now });
                            ownerPer.User = ownerUser;
                            db.Persons.InsertOnSubmit(ownerPer);
                        }
                        else if (!ownerPer.User.UsersInRoles.Any<Ajancy.UsersInRole>(ur => ur.RoleID == (short)Public.Role.CarOwner))
                        {
                            ownerPer.User.UsersInRoles.Add(new Ajancy.UsersInRole { RoleID = (short)Public.Role.CarOwner, MembershipDate = DateTime.Now, LockOutDate = DateTime.Now });
                        }

                        ownerPer.FirstName = this.txtOwnerName.Text.Trim();
                        ownerPer.LastName = this.txtOwnerFamily.Text.Trim();
                        ownerPer.CarPlateNumbers.Add(carPlateNumber);
                    }
                    else
                    {
                        person.CarPlateNumbers.Add(carPlateNumber);
                        if (carPlateNumber.OwnerPersonID > 0 && carPlateNumber.OwnerPersonID != person.PersonID) // Set driver as owner again
                        {
                            carPlateNumber.Person = person;
                        }
                    }
                }
            }

            #endregion

            if (this.ViewState["Mode"] == null) // Add mode
            {
                Ajancy.FuelCardSubstitution formerReq = null;
                if (fuelCard.FuelCardID > 0)
                {
                    formerReq = db.FuelCardSubstitutions.FirstOrDefault<Ajancy.FuelCardSubstitution>(fcs => (fcs.AjancyTypeFuelCardID == fuelCard.FuelCardID || fcs.PersonalTypeFuelCardID.GetValueOrDefault() == fuelCard.FuelCardID));
                    if (formerReq != null)
                    {
                        this.lblMessage.Text = "برای کارت سوخت بخش آژانسی قبلا درخواست ابطال یا جایگزین ثبت شده است";
                        return;
                    }
                }
                if (fuelCard_2.FuelCardID > 0)
                {
                    formerReq = db.FuelCardSubstitutions.FirstOrDefault<Ajancy.FuelCardSubstitution>(fcs => (fcs.AjancyTypeFuelCardID == fuelCard_2.FuelCardID || fcs.PersonalTypeFuelCardID.GetValueOrDefault() == fuelCard_2.FuelCardID));
                    if (formerReq != null)
                    {
                        this.lblMessage.Text = "برای کارت سوخت بخش شخصی قبلا درخواست ابطال یا جایگزین ثبت شده است";
                        return;
                    }
                }

                Ajancy.FuelCardSubstitution fcsReq = new Ajancy.FuelCardSubstitution
                {
                    FuelCard = fuelCard,
                    UserInRoleID = Public.ActiveUserRole.UserRoleID,
                    SubmitDate = DateTime.Now
                };

                db.FuelCardSubstitutions.InsertOnSubmit(fcsReq);
                db.SubmitChanges();
                fcsReq.PersonalTypeFuelCardID = fuelCard_2.FuelCardID;
            }
            else // Edit mode
            {
                db.FuelCardSubstitutions.FirstOrDefault<Ajancy.FuelCardSubstitution>(fcs => (fcs.AjancyTypeFuelCardID == fuelCard.FuelCardID && fcs.PersonalTypeFuelCardID.GetValueOrDefault() == fuelCard_2.FuelCardID)).SubmitDate = DateTime.Now;
            }

            db.SubmitChanges();
            DisposeContext();
            Response.Redirect("~/Message.aspx?mode=11");
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:101,代码来源:FCReplacement.aspx.cs

示例15: btnLogin_Click

    protected void btnLogin_Click(object sender, System.EventArgs e)
    {
        if (Page.IsValid)
        {
            DataLoadOptions dlo = new DataLoadOptions();

            if (this.trMembership.Visible && this.drpMemberships.SelectedItem != null) // login with selected membership
            {
                string[] roleParts = this.drpMemberships.SelectedValue.Split('|');
                dlo.LoadWith<Ajancy.UsersInRole>(u => u.User);
                dlo.LoadWith<Ajancy.User>(u => u.Person);
                db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
                db.LoadOptions = dlo;
                Ajancy.UsersInRole userInRole = db.UsersInRoles.First<Ajancy.UsersInRole>(ur => ur.UserRoleID == int.Parse(roleParts[0]));
                userInRole.LastLoginDate = DateTime.Now;
                db.SubmitChanges();
                this.LogIn(userInRole, roleParts);
            }

            dlo.LoadWith<Ajancy.User>(u => u.UsersInRoles);
            dlo.LoadWith<Ajancy.User>(u => u.Person);
            dlo.LoadWith<Ajancy.UsersInRole>(ur => ur.AjancyPartners);
            dlo.LoadWith<Ajancy.AjancyPartner>(jp => jp.Ajancy);
            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
            db.LoadOptions = dlo;
            Ajancy.User user = db.Users.FirstOrDefault<Ajancy.User>(u => u.UserName == this.txtUserName.Text && u.PassWord == FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassword.Text, "SHA1") && u.LockOutDate == null);

            if (user != null) // Credentials are valid
            {
                foreach (Ajancy.UsersInRole ur in user.UsersInRoles)
                {
                    if (ur.LockOutDate == null)
                    {
                        if (ur.AjancyPartners.Count == 0)
                        {
                            this.drpMemberships.Items.Add(new ListItem(Public.GetRoleName(ur.RoleID), string.Concat(ur.UserRoleID, "|0")));
                        }
                        else
                        {
                            foreach (Ajancy.AjancyPartner partner in ur.AjancyPartners)
                            {
                                if (partner.LockOutDate == null)
                                {
                                    if (partner.Ajancy == null)
                                    {
                                        this.drpMemberships.Items.Add(new ListItem(string.Concat(Public.GetRoleName(ur.RoleID), " --- ", partner.Ajancy == null ? null : partner.Ajancy.AjancyName), string.Concat(ur.UserRoleID, "|0|0|---")));
                                    }
                                    else
                                    {
                                        this.drpMemberships.Items.Add(new ListItem(string.Concat(Public.GetRoleName(ur.RoleID), " --- ", partner.Ajancy == null ? null : partner.Ajancy.AjancyName), string.Concat(ur.UserRoleID, "|", partner.AjancyID, "|", partner.Ajancy.AjancyType, "|", partner.Ajancy.AjancyName)));
                                    }
                                }
                            }
                        }
                    }
                }

                if (this.drpMemberships.Items.Count == 1) // login immediately
                {
                    user.UsersInRoles[0].LastLoginDate = DateTime.Now;
                    db.SubmitChanges();
                    string[] roleParts = this.drpMemberships.Items[0].Value.Split('|');
                    this.LogIn(user.UsersInRoles.First<Ajancy.UsersInRole>(ur => ur.UserRoleID.ToString() == roleParts[0]), roleParts);
                }
                else if (this.drpMemberships.Items.Count > 1) // several active roles are found
                {
                    this.DisposeContext();
                    this.trMembership.Visible = true;
                }
                else // no active role found
                {
                    this.lblMessage.Text = "برای این کاربر پست فعالی یافت نشد";
                }
            }
            else
            {
                this.lblMessage.Text = "نام کاربری یا گذرواژه نادرست میباشد";
            }
        }
    }
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:80,代码来源:Login.aspx.cs


注:本文中的Ajancy.Kimia_Ajancy.SubmitChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。