Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IUBAT13wfa.DAL.Customer ctm = new IUBAT13wfa.DAL.Customer();
            GridView1.DataSource = ctm.Select().Tables[0];

            GridView1.DataBind();
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblEName.Text    = "";
            lblEContact.Text = "";
            lblEEmail.Text   = "";
            lblEGender.Text  = "";
            lblEAddress.Text = "";
            lblECity.Text    = "";

            lblMessage.Text = "";


            int er = 0;

            if (txtName.Text == "")
            {
                er++;
                lblEName.Text = "Required";
            }
            if (txtContact.Text == "")
            {
                er++;
                lblEContact.Text = "Required";
            }
            if (txtEmail.Text == "")
            {
                er++;
                lblEEmail.Text = "Required";
            }
            if (txtAddress.Text == "")
            {
                er++;
                lblEAddress.Text = "Required";
            }

            if (ddlGender.SelectedIndex == 0)
            {
                er++;
                lblEGender.Text = "Required";
            }
            if (ddlCity.SelectedIndex == 0)
            {
                er++;
                lblECity.Text = "Required";
            }
            if (er > 0)
            {
                return;
            }

            IUBAT13wfa.DAL.Customer ctm = new IUBAT13wfa.DAL.Customer();
            ctm.Name    = txtName.Text;
            ctm.Contact = txtContact.Text;
            ctm.Email   = txtEmail.Text;
            // ctm.Gender = Convert.ToInt32(ddlGender.SelectedValue);
            ctm.Address = txtAddress.Text;
            ctm.CityId  = Convert.ToInt32(ddlCity.SelectedValue);

            if (ctm.Insert())
            {
                lblMessage.ForeColor  = System.Drawing.Color.Green;
                lblMessage.Text       = "Customer Inserted";
                txtName.Text          = "";
                ddlCity.SelectedIndex = 0;
                txtName.Focus();
            }
            else
            {
                lblMessage.Text      = ctm.Error;
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
        }