protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Int16 Emp_ID = Convert.ToInt16(args.Value);
            bool  DoesntExistsInDatabase = false;

            using (var db = new MGO_Entities())
            {
                DoesntExistsInDatabase = (from Employee in db.Employees
                                          where Employee.Emp_ID == Emp_ID
                                          select Employee).IsNull();
            }

            args.IsValid = DoesntExistsInDatabase;
        }
Example #2
0
        protected void CustomValidator3_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Int16 Cat_Num = Convert.ToInt16(args.Value);
            bool  DoesntExistsInDatabase = false;

            using (var db = new MGO_Entities())
            {
                DoesntExistsInDatabase = (from category in db.Categories
                                          where category.Cat_Num == Cat_Num
                                          select category).IsNull();
            }

            args.IsValid = DoesntExistsInDatabase;
        }
Example #3
0
        protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
        {
            string Cat_Description        = args.Value;
            bool   DoesntExistsInDatabase = false;

            using (var db = new MGO_Entities())
            {
                DoesntExistsInDatabase = (from category in db.Categories
                                          where category.Cat_Description == Cat_Description
                                          select category).IsNull();
            }

            args.IsValid = DoesntExistsInDatabase;
        }
Example #4
0
        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Int16 Cust_ID = Convert.ToInt16(args.Value);
            bool  DoesntExistsInDatabase = false;

            using (var db = new MGO_Entities())
            {
                DoesntExistsInDatabase = (from Customer in db.Customers
                                          where Customer.Cust_ID == Cust_ID
                                          select Customer).IsNull();
            }

            args.IsValid = DoesntExistsInDatabase;
        }
Example #5
0
        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Int16 SKU = Convert.ToInt16(args.Value);
            bool  DoesntExistsInDatabase = false;

            using (var db = new MGO_Entities())
            {
                DoesntExistsInDatabase = (from item in db.Items
                                          where item.SKU == SKU
                                          select item).IsNull();
            }

            args.IsValid = DoesntExistsInDatabase;
            DisplayForm();
        }
Example #6
0
        protected void getCat_Descript(object sender, string id, View view = View.Form, FormView formView = null)
        {
            //SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MGOConnectionString"].ConnectionString);
            //connection.Open();
            //string query = $@"Select [Cat_Description]
            //            FROM CATEGORY
            //            WHERE Cat_Num = {Convert.ToInt16((sender as DropDownList).SelectedValue)}";
            //SqlCommand selectCommand = new SqlCommand(query, connection);
            //SqlDataReader sqlData = selectCommand.ExecuteReader();
            //string Cat_Descript = "";

            //while (sqlData.Read())
            //{
            //    Cat_Descript = (string)sqlData["Cat_Description"];
            //}
            //sqlData.Close();
            //connection.Close();

            string Cat_Descript;
            short  Cat_Num = Convert.ToInt16((sender as DropDownList).SelectedValue);

            using (var db = new MGO_Entities())
            {
                Cat_Descript = (from category in db.Categories
                                where category.Cat_Num == Cat_Num
                                select category.Cat_Description).SingleOrDefault();
            }

            if (view == View.Form)
            {
                if (formView.CurrentMode == FormViewMode.Insert)
                {
                    (formView.FindControl(id) as Label).Text = Cat_Descript;
                }
                else if (formView.CurrentMode == FormViewMode.Edit)
                {
                    (formView.FindControl(id) as TextBox).Text = Cat_Descript;
                }
            }
            else
            {
                (grdviewProducts.Rows[grdviewProducts.EditIndex].FindControl(id) as Label).Text = Cat_Descript;
            }
        }