Exemple #1
0
        public ActionResult SaveCompany(Company company)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    company.ActionDate = DateTime.Now.ToString();
                    company.ActionType = ActionType.Insert;
                    company.ActionBy   = ActionType.User;

                    ViewBag.Response = companyManager.Add(company);
                }
                else
                {
                    ViewBag.Response = 3;
                }

                ModelState.Clear();
                return(View());
            }
            else
            {
                return(HttpNotFound());
            }
        }
Exemple #2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (nameTextBox.Text == "")
                {
                    nameLlabel.Text      = "Enter a Company";
                    nameLlabel.ForeColor = Color.Red;
                    return;
                }
                _company.Name = nameTextBox.Text.Trim();

                bool isExist = _companyManager.IsDuplicateData(_company);
                if (isExist)
                {
                    nameLlabel.Text      = $"Company {nameTextBox.Text} already in system";
                    nameLlabel.ForeColor = Color.Red;
                    nameTextBox.Clear();
                    return;
                }
                bool isAdded = _companyManager.Add(_company);
                if (isAdded)
                {
                    nameLlabel.Text = $"Save company: {nameTextBox.Text} successfully";
                    GetData();
                    nameTextBox.Clear();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemple #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Model.Company company = new Model.Company();
            company.Name = nameTextBox.Text;

            SqlConnection _con           = new SqlConnection(Model.Common.ConnectionString());
            string        QueryDuplicate = @"SELECT COUNT(*) FROM Companies where Name='" + company.Name + "' ";

            SqlCommand     commandDuplicateCheck = new SqlCommand(QueryDuplicate, _con);
            DataTable      ds = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(commandDuplicateCheck);

            da.Fill(ds);
            if (ds.Rows[0][0].ToString() == "1")
            {
                string msg = "Duplicate Entry not Allowed.";
                MessageBox.Show(msg);
            }
            else
            {
                bool isAdded = _companyManager.Add(company: company);
                if (isAdded)
                {
                    MessageBox.Show("Successfully Saved.");
                    nameTextBox.Clear();
                    CompanyLode();
                    return;
                }
                MessageBox.Show("Sory! Saved failed");
            }
        }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                Company company = new Company();
                company.Name = nameTextBox.Text;
                if (company.Name == String.Empty || company.Name.Length < 2)
                {
                    errorProvider.SetError(nameTextBox, "Please provide a valid company!");
                }

                bool isAdded = _manager.Add(company);
                if (isAdded)
                {
                    Reset(this.Controls);
                    _dataTable = _manager.GetCompanies();
                    for (int i = 0; i < _dataTable.Rows.Count; i++)
                    {
                        companyDataGridView.Rows.Add(_dataTable.Rows[i].Field <int>("Id"), _dataTable.Rows[i].Field <string>("Name"));
                    }
                }
                else
                {
                    MessageBox.Show("Error Occured While Saving!");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemple #5
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Core.Entity.Company Company = new Core.Entity.Company();
     Company.Address     = txtAddress.Text;
     Company.CompanyName = txtCompanyName.Text;
     Company.CompanyReg  = txtCompanyReg.Text;
     companyManager.Add(Company);
     BindCompanyGrid();
 }
Exemple #6
0
        public ActionResult Add(AddCompanyVM model)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Account"));
            }
            ViewBag.ReportTitle = "Add New Company";

            //var selectedRoles = model.Roles.Where(x => x.IsChecked).Select(x => x.ID).ToList();
            //var selectedCompanies = model.Companies.Where(x => x.IsChecked).Select(x => x.ID).ToList();
            CompanyManager.Add(model);
            return(RedirectToAction("Index"));
        }
Exemple #7
0
        /// <summary>
        /// 1、先在default数据库内注册公司
        /// 2、新建数据库(即拷贝一份空数据库,以公司简称为文件名)
        /// 3、在新建数据库内插入公司记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        //public ActionResult CreateEntity(CompanyRegister model)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return Json(
        //            new OperateResult
        //            {
        //                content = Model.Utility.GetModelStateErrors(ModelState),
        //            },
        //            JsonRequestBehavior.AllowGet
        //        );
        //    }

        //    CompanyRegisterManager manager = new CompanyRegisterManager();

        //    OperateResult or = manager.AddRegister(model);
        //    if (or.status == OperateStatus.Success)
        //    {
        //        //从空数据库复制一份
        //        string dbSrc = Server.MapPath("/") + "App_Data/sqliteDefault.db";
        //        string dbDst = Server.MapPath("/") + "App_Data/sqlite" + model.code + ".db";

        //        System.IO.File.Copy(dbSrc, dbDst);

        //        Company c = new Company
        //        {
        //            name = model.name,
        //            code = model.code
        //        };

        //        CompanyManager m = new CompanyManager();
        //        or = m.Add(c);
        //    }

        //    return Json(or, JsonRequestBehavior.AllowGet);

        //}

        public ActionResult CreateEntity(Company model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(
                           new OperateResult
                {
                    content = Model.Utility.GetModelStateErrors(ModelState),
                },
                           JsonRequestBehavior.AllowGet
                           ));
            }

            OperateResult or = CompanyManager.Add(model);

            return(Json(or, JsonRequestBehavior.AllowGet));
        }
Exemple #8
0
        //*****************************************************************//

        private void SaveButton_Click(object sender, EventArgs e)
        {
            company.CompanyName = CompanyNameTextBox.Text;
            if (companyManager.Validation(company.CompanyName))
            {
                bool isAdded = companyManager.Add(company);
                if (isAdded)
                {
                    DataTable dt = companyManager.Show();
                    CompanyDataGridView.DataSource = dt;
                    CompanyNameTextBox.Text        = String.Empty;
                }
                else
                {
                    MessageBox.Show("Cateegory already Registered!");
                }
            }

            else
            {
                MessageBox.Show("Invalid Category Name. Use atleast One Letter!!!");
            }
        }