예제 #1
0
        protected void cmdSubmit_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                lblError.Text = "Please enter a company name.";
                return;
            }
            else
            {
                lblError.Text = "";
            }
            _currentCompany = (TimeCompanies)Session["CurrentCompany"];
            if (_currentCompany == null)
            {
                //new company object
                TimeCompanies company = TimeCompanies.New();

                //fill object with data
                company.CompanyName = txtName.Text;
                company.Description = txtDescription.Text;
                company.Status = 1;
                company.Type = 1;

                //save the new company
                company.Save();
            }
            else
            {
                _currentCompany.CompanyName = txtName.Text;
                _currentCompany.Description = txtDescription.Text;
                _currentCompany.Status = 1;
                _currentCompany.Type = 1;

                //save the new company
                _currentCompany.Save();
            }

            txtName.Text = "";
            txtDescription.Text = "";
            _currentCompany = null;
            Session["CurrentCompany"] = _currentCompany;
            RefreshEntries();
            updEntries.Update();

            lblSuccessMessage.Text = "Successfully submitted data!";
            mpSuccess.Show();
        }
예제 #2
0
        //protected void btnDelete_Click(object sender, CommandEventArgs e)
        //{
        //    TimeCompanies bpe = TimeCompanies.ReadSafe(Convert.ToInt32(e.CommandArgument));
        //    if (bpe != null)
        //    {
        //        bpe.Delete();
        //        RefreshEntries();
        //        updEntries.Update();
        //    }
        //}
        protected void rptCompanies_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                string allKeys = Convert.ToString(e.CommandArgument);
                int pkID = Convert.ToInt32(allKeys);
                _currentCompany = TimeCompanies.Read(pkID);
                Session["CurrentCompany"] = _currentCompany;
                txtName.Text = _currentCompany.CompanyName;
                txtDescription.Text = _currentCompany.Description;
            }

            if (e.CommandName == "Delete")
            {
                string allKeys = Convert.ToString(e.CommandArgument);
                int pkID = Convert.ToInt32(allKeys);
                _currentCompany = TimeCompanies.Read(pkID);
                _currentCompany.Delete();
                _currentCompany = null;
                Session["CurrentCompany"] = _currentCompany;
                RefreshEntries();
                updEntries.Update();
                lblSuccessMessage.Text = "Successfully deleted data!";
                mpSuccess.Show();
            }
        }