示例#1
0
 private void sbAgree_Click(object sender, EventArgs e)
 {
     DB.Signing tmpSign = dbContext.Signing.Where(x => x.ID == currentID).ToList()[0];
     tmpSign.IsAgreed = true;
     tmpSign.Date     = DateTime.Now;
     dbContext.SaveChanges();
     Close();
 }
        public ActionResult DeleteInfo(string id, FormCollection collection)
        {
            DB.DBModel db    = new DB.DBModel();
            var        quary = (from item in db.User where item.Name == id select item);

            db.User.RemoveRange(quary);
            db.SaveChanges();
            return(RedirectToAction("Info"));
        }
        public ActionResult ChangeCompany(FormCollection collection)
        {
            int ID = int.Parse(collection["ID"]);

            DB.DBModel db = new DB.DBModel();
            DB.Company c  = (from item in db.Company where item.ID == ID select item).FirstOrDefault();
            c.Name = collection["Name"];
            db.SaveChanges();
            return(RedirectToAction("Company"));
        }
 public ActionResult CreateCompany(FormCollection collection)
 {
     DB.DBModel db = new DB.DBModel();
     DB.Company c  = new DB.Company()
     {
         Name = collection["Name"]
     };
     db.Company.Add(c);
     db.SaveChanges();
     return(RedirectToAction("CreateCompany"));
 }
        public ActionResult DeleteCompany(string id, FormCollection collection)
        {
            int ID = int.Parse(id);

            DB.DBModel db    = new  DB.DBModel();
            var        query = from item in db.Company where item.ID == ID select item;

            db.Company.RemoveRange(query);
            db.SaveChanges();
            return(RedirectToAction("Company"));
        }
        public ActionResult ChangeInfo(FormCollection collection)
        {
            string ID = collection["Name"];

            DB.DBModel db = new DB.DBModel();
            DB.User    c  = (from item in db.User where item.Name == ID select item).FirstOrDefault();
            c.Name           = collection["Name"];
            c.Login          = collection["Login"];
            c.Password       = collection["Password"];
            c.IDCompany      = int.Parse(collection["IDCompany"]);
            c.StatusContract = collection["StatusContract"];
            db.SaveChanges();
            return(RedirectToAction("Info"));
        }
 public ActionResult CreateUser(FormCollection collection)
 {
     DB.DBModel db = new DB.DBModel();
     DB.User    c  = new DB.User()
     {
         Name           = collection["Name"],
         Login          = collection["Login"],
         Password       = collection["Password"],
         IDCompany      = int.Parse(collection["IDCompany"]),
         StatusContract = collection["StatusContract"],
     };
     db.User.Add(c);
     db.SaveChanges();
     return(RedirectToAction("CreateUser"));
 }
示例#8
0
        public void SaveContractorChanges()
        {
            if (teName.Text == "")
            {
                currentContractor.Name = null;
            }
            else
            if (currentContractor.Name != teName.Text)
            {
                currentContractor.Name = teName.Text;
            }
            //
            if (meFullName.Text == "")
            {
                currentContractor.FullName = null;
            }
            else
            if (currentContractor.FullName != meFullName.Text)
            {
                currentContractor.FullName = meFullName.Text;
            }
            //
            if (teEGRPOU.Text == "")
            {
                currentContractor.EDRPOU = null;
            }
            else
            if (currentContractor.EDRPOU != teEGRPOU.Text)
            {
                currentContractor.EDRPOU = teEGRPOU.Text;
            }
            //
            if (teEGRPOU.Text == "")
            {
                currentContractor.EDRPOU = null;
            }
            else
            if (currentContractor.EDRPOU != teEGRPOU.Text)
            {
                currentContractor.EDRPOU = teEGRPOU.Text;
            }
            //
            if (teLegalAddress.Text == "")
            {
                currentContractor.LegalAddress = null;
            }
            else
            if (currentContractor.LegalAddress != teLegalAddress.Text)
            {
                currentContractor.LegalAddress = teLegalAddress.Text;
            }
            //
            if (teActualAddress.Text == "")
            {
                currentContractor.ActualAddress = null;
            }
            else
            if (currentContractor.ActualAddress != teActualAddress.Text)
            {
                currentContractor.ActualAddress = teActualAddress.Text;
            }
            //
            if (teTaxCode.Text == "")
            {
                currentContractor.TaxCode = null;
            }
            else
            if (currentContractor.TaxCode != teTaxCode.Text)
            {
                currentContractor.TaxCode = teTaxCode.Text;
            }
            //
            if (teEngCode.Text == "")
            {
                currentContractor.EngCode = null;
            }
            else
            if (currentContractor.EngCode != teEngCode.Text)
            {
                currentContractor.EngCode = teEngCode.Text;
            }
            //
            if (teCheckingAccount.Text == "")
            {
                currentContractor.CheckingAccount = null;
            }
            else
            if (currentContractor.CheckingAccount != teCheckingAccount.Text)
            {
                currentContractor.CheckingAccount = teCheckingAccount.Text;
            }
            //
            if (tePhoneNumber.Text == "")
            {
                currentContractor.PhoneNumber = null;
            }
            else
            if (currentContractor.PhoneNumber != tePhoneNumber.Text)
            {
                currentContractor.PhoneNumber = tePhoneNumber.Text;
            }
            //
            if (teEmail.Text == "")
            {
                currentContractor.Email = null;
            }
            else
            if (currentContractor.Email != teEmail.Text)
            {
                currentContractor.Email = teEmail.Text;
            }
            //
            if (lueGroup.Text != "" && lueGroup.EditValue != null && currentContractor.ContractorTypeID != (int)lueGroup.EditValue)
            {
                currentContractor.ContractorTypeID = (int)lueGroup.EditValue;
            }
            //
            if (lueTaxType.Text != "" && lueTaxType.EditValue != null && currentContractor.TaxTypeID != (int)lueTaxType.EditValue)
            {
                currentContractor.TaxTypeID = (int)lueTaxType.EditValue;
            }

            if (currentID == 0)
            {
                dbContext.Contractors.Add(currentContractor);
            }

            dbContext.SaveChanges();
        }
示例#9
0
        public void SaveContracChanges()
        {
            if (lueContractCategory.Text != "" && lueContractCategory.EditValue != null && currContract.CategoryID != (int)lueContractCategory.EditValue)
            {
                currContract.CategoryID = (int)lueContractCategory.EditValue;
            }
            if (lueDepartment.Text != "" && lueDepartment.EditValue != null && currContract.DepartmentID != (int)lueDepartment.EditValue)
            {
                currContract.DepartmentID = (int)lueDepartment.EditValue;
            }
            if (lueContractual.Text != "" && lueContractual.EditValue != null && currContract.ContractualID != (int)lueContractual.EditValue)
            {
                currContract.ContractualID = (int)lueContractual.EditValue;
            }
            if (lueExtensions.Text != "" && lueExtensions.EditValue != null && currContract.ContractRenewalID != (int)lueExtensions.EditValue)
            {
                currContract.ContractRenewalID = (int)lueExtensions.EditValue;
            }
            if (lueContractors.Text != "" && lueContractors.EditValue != null && currContract.ContractorID != (int)lueContractors.EditValue)
            {
                currContract.ContractorID = (int)lueContractors.EditValue;
            }
            if (teSumm.Text != "" && currContract.Summ != Convert.ToDouble(teSumm.Text))
            {
                currContract.Summ = Convert.ToDouble(teSumm.Text);
            }
            else if (teSumm.Text == "")
            {
                currContract.Summ = null;
            }

            if (teContractNote.Text == "")
            {
                currContract.Note = null;
            }
            else
            if (currContract.Note != teContractNote.Text)
            {
                currContract.Note = teContractNote.Text;
            }

            if (teContractTheme.Text == "")
            {
                currContract.Theme = null;
            }
            else
            if (currContract.Theme != teContractTheme.Text)
            {
                currContract.Theme = teContractTheme.Text;
            }

            if (deDate.Text == "")
            {
                currContract.Date = null;
            }
            else
            if (currContract.Date != Convert.ToDateTime(deDate.Text))
            {
                currContract.Date = Convert.ToDateTime(deDate.Text);
            }

            if (deContractDateEnd.Text == "")
            {
                currContract.EndDate = null;
            }
            else
            if (currContract.EndDate != Convert.ToDateTime(deContractDateEnd.Text))
            {
                currContract.EndDate = Convert.ToDateTime(deContractDateEnd.Text);
            }

            if (deContractDateStart.Text == "")
            {
                currContract.StartDate = null;
            }
            else
            if (currContract.StartDate != Convert.ToDateTime(deContractDateStart.Text))
            {
                currContract.StartDate = Convert.ToDateTime(deContractDateStart.Text);
            }
            currContract.AuthorID = Properties.Settings.CurrentUserID;

            string number = string.Empty;
            string day    = currContract.Date.Value.Day.ToString();

            if (day.Length == 1)
            {
                day = "0" + day;
            }
            string month = currContract.Date.Value.Month.ToString();

            if (month.Length == 1)
            {
                month = "0" + month;
            }
            string year = currContract.Date.Value.Year.ToString();

            year = year.Substring(2);
            int    today_number     = dbContext.Contracts.Where(x => x.Date == DateTime.Today).Count() + 1;
            string prefix           = dbContext.Departments.Where(x => x.ID == currContract.DepartmentID).Select(y => y.Prefix).ToList()[0].ToString();
            string nomenclature     = "8";
            string department_index = "?";

            number = day + month + year + "-" + today_number.ToString() + prefix + nomenclature + "/" + department_index;
            //if (currContract.Number == null)
            currContract.Number = number;

            DB.ContractMovements movements = new DB.ContractMovements();
            movements.ContractID = currContract.ID;
            movements.Date       = DateTime.Now;
            movements.AuthorID   = Properties.Settings.CurrentUserID;

            if (this.currentID == 0)
            {
                dbContext.Contracts.Add(currContract);
                Text = "Договор № " + currContract.Number + " от " + String.Format("{0:dd/MM/yyyy}", currContract.Date);
                movements.MovementTypeID = 1;
            }
            else
            {
                movements.MovementTypeID = 2;
            }
            dbContext.ContractMovements.Add(movements);
            dbContext.SaveChanges();
            teContractNumber.Text = currContract.Number;
            currentID             = currContract.ID;
            isLoaded = true;
            FillMovements();
        }