Пример #1
0
        //END - create

        //BEGIN - update
        public void UpdateCustomercustomerdemo(CustomercustomerdemoSingle customercustomerdemo)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        using (SqlCommand cmd = new SqlCommand("spUpdateCustomercustomerdemo", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        })
                        {
                            cmd.Parameters.AddWithValue("@CustomerID", customercustomerdemo.CustomerID);
                            cmd.Parameters.AddWithValue("@CustomerTypeID", customercustomerdemo.CustomerTypeID);
                            con.Open();
                            cmd.ExecuteNonQuery();
                        }
                        con.Close();
                    }
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    //errResult = "A Technical Error occurred, Please visit after some time.";
                    throw;
                }
            }
            catch (Exception fx)
            {
                errResult = fx.Message.ToString();
                throw;
            }
        }
Пример #2
0
        //END - delete


        //BEGIN - read
        public List <CustomercustomerdemoSingle> GetAllCustomercustomerdemos()
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    List <CustomercustomerdemoSingle> customercustomerdemos = new List <CustomercustomerdemoSingle>();

                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        SqlCommand cmd = new SqlCommand("spGetAllCustomercustomerdemo", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        };

                        con.Open();

                        SqlDataReader rdr = cmd.ExecuteReader();

                        while (rdr.Read())
                        {
                            CustomercustomerdemoSingle customercustomerdemo = new CustomercustomerdemoSingle
                            {
                                // EXAMPLES:
                                //EmployeeId = Convert.ToInt32(rdr["EmployeeId"]),
                                //Name = rdr["Name"].ToString(),
                                //IsPermanent = (bool)rdr["IsPermanent"],
                                //Salary = Convert.ToDecimal(rdr["Salary"]),
                                //DateOfBirth = Convert.ToDateTime(rdr["DateOfBirth"])

                                //CustomerID = (string)rdr["CustomerID"]
                                CustomerID = rdr["CustomerID"] == DBNull.Value ? "" : (string)rdr["CustomerID"]
                                             //,CustomerTypeID = (string)rdr["CustomerTypeID"]
                                ,
                                CustomerTypeID = rdr["CustomerTypeID"] == DBNull.Value ? "" : (string)rdr["CustomerTypeID"]
                            };
                            customercustomerdemos.Add(customercustomerdemo);
                        }
                        con.Close();
                        cmd.Dispose();
                    }
                    return(customercustomerdemos);
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    //errResult = "A Technical Error occurred, Please visit after some time.";
                    throw;
                }
            }
            catch (Exception fx)
            {
                errResult = fx.Message.ToString();
                throw;
            }
        }
Пример #3
0
        //BEGIN - readBy
        public CustomercustomerdemoSingle GetCustomercustomerdemoData(string CustomerID)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    CustomercustomerdemoSingle customercustomerdemo = new CustomercustomerdemoSingle();
                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        string sqlQuery = "SELECT * FROM [CustomerCustomerDemo] WHERE CustomerID= '" + CustomerID.ToString() + "'";

                        using (SqlCommand cmd = new SqlCommand(sqlQuery, con))
                        {
                            con.Open();
                            SqlDataReader rdr = cmd.ExecuteReader();
                            while (rdr.Read())
                            {
                                //customercustomerdemo.CustomerID = (string)rdr["CustomerID"];
                                customercustomerdemo.CustomerID = rdr["CustomerID"] == DBNull.Value ? "" : (string)rdr["CustomerID"];

                                //customercustomerdemo.CustomerTypeID = (string)rdr["CustomerTypeID"];
                                customercustomerdemo.CustomerTypeID = rdr["CustomerTypeID"] == DBNull.Value ? "" : (string)rdr["CustomerTypeID"];


                                //EXAMPLES:
                                //employee.EmployeeId = Convert.ToInt32(rdr["EmployeeID"]);
                                //employee.Name = rdr["Name"].ToString();
                                //employee.Gender = rdr["Gender"].ToString();
                                //employee.Salary = (decimal)rdr["Salary"];
                                //employee.City = rdr["City"].ToString();
                                //employee.IsPermanent = (bool)rdr["IsPermanent"];
                                //employee.DateOfBirth = Convert.ToDateTime(rdr["DateOfBirth"]);
                            }
                        }
                    }
                    return(customercustomerdemo);
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    //errResult = "A Technical Error occurred, Please visit after some time.";
                    throw;
                }
            }
            catch (Exception fx)
            {
                errResult = fx.Message.ToString();
                throw;
            }
        }
Пример #4
0
        public ActionResult Create_Post()
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    CustomersBusinessModelLayers customersLUBusinessModelLayers = new CustomersBusinessModelLayers();
                    ViewBag.Customerss = new SelectList(customersLUBusinessModelLayers.CustomersSelect, "CustomerID", "CompanyName");
                    CustomerdemographicsBusinessModelLayers customerdemographicsLUBusinessModelLayers = new CustomerdemographicsBusinessModelLayers();
                    ViewBag.CustomerDemographicss = new SelectList(customerdemographicsLUBusinessModelLayers.CustomerdemographicsSelect, "CustomerTypeID", "CustomerDesc");

                    CustomercustomerdemoBusinessModelLayers       customercustomerdemoBusinessModelLayers = new CustomercustomerdemoBusinessModelLayers();
                    BusinessModelLayer.CustomercustomerdemoSingle customercustomerdemo = new BusinessModelLayer.CustomercustomerdemoSingle();
                    TryUpdateModel(customercustomerdemo);
                    if (ModelState.IsValid)
                    {
                        //mm
                        customercustomerdemoBusinessModelLayers.AddCustomercustomerdemo(customercustomerdemo);
                        return(RedirectToAction("List"));
                    }
                    else
                    {
                        return(View());
                    }
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }