Esempio n. 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            ep.Clear();
            if (cmbCategoryList.SelectedIndex == 0)
            {
                ep.SetError(cmbCategoryList, "Please Select Category Name");
                cmbCategoryList.Focus();
                return;
            }
            if (txtGeneralName.Text.Trim().Length == 0)
            {
                ep.SetError(txtGeneralName, "Please Enter General Name");
                txtGeneralName.Focus();
                txtGeneralName.SelectAll();
                return;
            }
            if (txtUserFOr.Text.Trim().Length == 0)
            {
                ep.SetError(txtUserFOr, "Please Enter Using Detail of Product");
                txtUserFOr.Focus();
                txtUserFOr.SelectAll();
                return;
            }

            string sql = string.Format(@"UPDATE General SET categoryID = '{0}', gen_Name='{1}', usefor='{2}', description='{3}' WHERE gen_ID = '{4}'", CommonCodeClass.GetCategoryID(cmbCategoryList.Text.Trim()), txtGeneralName.Text, txtUserFOr.Text, txtDescription.Text, updateGeneralID);

            DataAccessLayer.Execute(sql);
            MessageBox.Show("General Product Successfully Updated...");
            btnCancel_Click(sender, e);
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ep.Clear();
            if (cmbCategoryList.SelectedIndex == 0)
            {
                ep.SetError(cmbCategoryList, "Please Select Category Name");
                cmbCategoryList.Focus();
                return;
            }
            if (txtGeneralName.Text.Trim().Length == 0)
            {
                ep.SetError(txtGeneralName, "Please Enter General Name");
                txtGeneralName.Focus();
                txtGeneralName.SelectAll();
                return;
            }
            if (txtUserFOr.Text.Trim().Length == 0)
            {
                ep.SetError(txtUserFOr, "Please Enter Using Detail of Product");
                txtUserFOr.Focus();
                txtUserFOr.SelectAll();
                return;
            }

            string sql = string.Format(@"INSERT INTO General (categoryID, gen_Name, usefor, description) VALUES ('{0}', '{1}', '{2}', '{3}')", CommonCodeClass.GetCategoryID(cmbCategoryList.Text.Trim()), txtGeneralName.Text, txtUserFOr.Text, txtDescription.Text);

            DataAccessLayer.Execute(sql);
            MessageBox.Show("General Product Successfully Added...");
            FillGrid("");
            ClearForm();
        }