//END - create

        //BEGIN - update
        public void UpdateTbl_Exceptionloggingtodatabase(Tbl_ExceptionloggingtodatabaseSingle tbl_exceptionloggingtodatabase)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    BusinessLayer.Validation isdte = new BusinessLayer.Validation();
                    if (isdte.IsDate(tbl_exceptionloggingtodatabase.Logdate) == false)
                    {
                        tbl_exceptionloggingtodatabase.Logdate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        using (SqlCommand cmd = new SqlCommand("spUpdateTbl_Exceptionloggingtodatabase", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        })
                        {
                            cmd.Parameters.AddWithValue("@Logid", tbl_exceptionloggingtodatabase.Logid);
                            cmd.Parameters.AddWithValue("@ExceptionMsg", (object)tbl_exceptionloggingtodatabase.ExceptionMsg ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ExceptionType", (object)tbl_exceptionloggingtodatabase.ExceptionType ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ExceptionSource", (object)tbl_exceptionloggingtodatabase.ExceptionSource ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ExceptionURL", (object)tbl_exceptionloggingtodatabase.ExceptionURL ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Logdate", (object)tbl_exceptionloggingtodatabase.Logdate ?? DBNull.Value);
                            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;
            }
        }
Example #2
0
        //END - create

        //BEGIN - update
        public void UpdateEmployees(EmployeesSingle employees)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    BusinessLayer.Validation isdte = new BusinessLayer.Validation();
                    if (isdte.IsDate(employees.BirthDate) == false)
                    {
                        employees.BirthDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    if (isdte.IsDate(employees.HireDate) == false)
                    {
                        employees.HireDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        using (SqlCommand cmd = new SqlCommand("spUpdateEmployees", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        })
                        {
                            cmd.Parameters.AddWithValue("@EmployeeID", employees.EmployeeID);
                            cmd.Parameters.AddWithValue("@LastName", employees.LastName);
                            cmd.Parameters.AddWithValue("@FirstName", employees.FirstName);
                            cmd.Parameters.AddWithValue("@Title", (object)employees.Title ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@TitleOfCourtesy", (object)employees.TitleOfCourtesy ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@BirthDate", (object)employees.BirthDate ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@HireDate", (object)employees.HireDate ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Address", (object)employees.Address ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@City", (object)employees.City ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Region", (object)employees.Region ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@PostalCode", (object)employees.PostalCode ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Country", (object)employees.Country ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@HomePhone", (object)employees.HomePhone ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Extension", (object)employees.Extension ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Photo", (object)employees.Photo ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Notes", (object)employees.Notes ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ReportsTo", (object)employees.ReportsTo ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@PhotoPath", (object)employees.PhotoPath ?? DBNull.Value);
                            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;
            }
        }
Example #3
0
        //END - readBy
        //BEGIN - create
        public void AddEmployees(EmployeesSingle employees)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    BusinessLayer.Validation isdte = new BusinessLayer.Validation();
                    if (isdte.IsDate(employees.BirthDate) == false)
                    {
                        employees.BirthDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    if (isdte.IsDate(employees.HireDate) == false)
                    {
                        employees.HireDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }


                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        SqlCommand cmd = new SqlCommand("spAddEmployees", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        };
                        SqlParameter paramEmployeeID = new SqlParameter
                        {
                            ParameterName = "@EmployeeID",
                            Value         = employees.EmployeeID
                        };
                        cmd.Parameters.Add(paramEmployeeID);

                        SqlParameter paramLastName = new SqlParameter
                        {
                            ParameterName = "@LastName",
                            Value         = employees.LastName
                        };
                        cmd.Parameters.Add(paramLastName);

                        SqlParameter paramFirstName = new SqlParameter
                        {
                            ParameterName = "@FirstName",
                            Value         = employees.FirstName
                        };
                        cmd.Parameters.Add(paramFirstName);

                        SqlParameter paramTitle = new SqlParameter
                        {
                            ParameterName = "@Title",
                            Value         = employees.Title
                        };
                        cmd.Parameters.Add(paramTitle);

                        SqlParameter paramTitleOfCourtesy = new SqlParameter
                        {
                            ParameterName = "@TitleOfCourtesy",
                            Value         = employees.TitleOfCourtesy
                        };
                        cmd.Parameters.Add(paramTitleOfCourtesy);

                        SqlParameter paramBirthDate = new SqlParameter
                        {
                            ParameterName = "@BirthDate",
                            Value         = employees.BirthDate
                        };
                        cmd.Parameters.Add(paramBirthDate);

                        SqlParameter paramHireDate = new SqlParameter
                        {
                            ParameterName = "@HireDate",
                            Value         = employees.HireDate
                        };
                        cmd.Parameters.Add(paramHireDate);

                        SqlParameter paramAddress = new SqlParameter
                        {
                            ParameterName = "@Address",
                            Value         = employees.Address
                        };
                        cmd.Parameters.Add(paramAddress);

                        SqlParameter paramCity = new SqlParameter
                        {
                            ParameterName = "@City",
                            Value         = employees.City
                        };
                        cmd.Parameters.Add(paramCity);

                        SqlParameter paramRegion = new SqlParameter
                        {
                            ParameterName = "@Region",
                            Value         = employees.Region
                        };
                        cmd.Parameters.Add(paramRegion);

                        SqlParameter paramPostalCode = new SqlParameter
                        {
                            ParameterName = "@PostalCode",
                            Value         = employees.PostalCode
                        };
                        cmd.Parameters.Add(paramPostalCode);

                        SqlParameter paramCountry = new SqlParameter
                        {
                            ParameterName = "@Country",
                            Value         = employees.Country
                        };
                        cmd.Parameters.Add(paramCountry);

                        SqlParameter paramHomePhone = new SqlParameter
                        {
                            ParameterName = "@HomePhone",
                            Value         = employees.HomePhone
                        };
                        cmd.Parameters.Add(paramHomePhone);

                        SqlParameter paramExtension = new SqlParameter
                        {
                            ParameterName = "@Extension",
                            Value         = employees.Extension
                        };
                        cmd.Parameters.Add(paramExtension);

                        SqlParameter paramPhoto = new SqlParameter
                        {
                            ParameterName = "@Photo",
                            Value         = employees.Photo
                        };
                        cmd.Parameters.Add(paramPhoto);

                        SqlParameter paramNotes = new SqlParameter
                        {
                            ParameterName = "@Notes",
                            Value         = employees.Notes
                        };
                        cmd.Parameters.Add(paramNotes);

                        SqlParameter paramReportsTo = new SqlParameter
                        {
                            ParameterName = "@ReportsTo",
                            Value         = employees.ReportsTo
                        };
                        cmd.Parameters.Add(paramReportsTo);

                        SqlParameter paramPhotoPath = new SqlParameter
                        {
                            ParameterName = "@PhotoPath",
                            Value         = employees.PhotoPath
                        };
                        cmd.Parameters.Add(paramPhotoPath);

                        con.Open();
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();
                    }
                }
                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;
            }
        }
        //END - readBy
        //BEGIN - create
        public void AddTbl_Exceptionloggingtodatabase(Tbl_ExceptionloggingtodatabaseSingle tbl_exceptionloggingtodatabase)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    BusinessLayer.Validation isdte = new BusinessLayer.Validation();
                    if (isdte.IsDate(tbl_exceptionloggingtodatabase.Logdate) == false)
                    {
                        tbl_exceptionloggingtodatabase.Logdate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }


                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        SqlCommand cmd = new SqlCommand("spAddTbl_Exceptionloggingtodatabase", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        };
                        SqlParameter paramLogid = new SqlParameter
                        {
                            ParameterName = "@Logid",
                            Value         = tbl_exceptionloggingtodatabase.Logid
                        };
                        cmd.Parameters.Add(paramLogid);

                        SqlParameter paramExceptionMsg = new SqlParameter
                        {
                            ParameterName = "@ExceptionMsg",
                            Value         = tbl_exceptionloggingtodatabase.ExceptionMsg
                        };
                        cmd.Parameters.Add(paramExceptionMsg);

                        SqlParameter paramExceptionType = new SqlParameter
                        {
                            ParameterName = "@ExceptionType",
                            Value         = tbl_exceptionloggingtodatabase.ExceptionType
                        };
                        cmd.Parameters.Add(paramExceptionType);

                        SqlParameter paramExceptionSource = new SqlParameter
                        {
                            ParameterName = "@ExceptionSource",
                            Value         = tbl_exceptionloggingtodatabase.ExceptionSource
                        };
                        cmd.Parameters.Add(paramExceptionSource);

                        SqlParameter paramExceptionURL = new SqlParameter
                        {
                            ParameterName = "@ExceptionURL",
                            Value         = tbl_exceptionloggingtodatabase.ExceptionURL
                        };
                        cmd.Parameters.Add(paramExceptionURL);

                        SqlParameter paramLogdate = new SqlParameter
                        {
                            ParameterName = "@Logdate",
                            Value         = tbl_exceptionloggingtodatabase.Logdate
                        };
                        cmd.Parameters.Add(paramLogdate);

                        con.Open();
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();
                    }
                }
                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;
            }
        }
Example #5
0
        //END - create

        //BEGIN - update
        public void UpdateOrders(OrdersSingle orders)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    BusinessLayer.Validation isdte = new BusinessLayer.Validation();
                    if (isdte.IsDate(orders.OrderDate) == false)
                    {
                        orders.OrderDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    if (isdte.IsDate(orders.RequiredDate) == false)
                    {
                        orders.RequiredDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    if (isdte.IsDate(orders.ShippedDate) == false)
                    {
                        orders.ShippedDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        using (SqlCommand cmd = new SqlCommand("spUpdateOrders", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        })
                        {
                            cmd.Parameters.AddWithValue("@OrderID", orders.OrderID);
                            cmd.Parameters.AddWithValue("@CustomerID", (object)orders.CustomerID ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@EmployeeID", (object)orders.EmployeeID ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@OrderDate", (object)orders.OrderDate ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@RequiredDate", (object)orders.RequiredDate ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShippedDate", (object)orders.ShippedDate ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShipVia", (object)orders.ShipVia ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@Freight", (object)orders.Freight ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShipName", (object)orders.ShipName ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShipAddress", (object)orders.ShipAddress ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShipCity", (object)orders.ShipCity ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShipRegion", (object)orders.ShipRegion ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShipPostalCode", (object)orders.ShipPostalCode ?? DBNull.Value);
                            cmd.Parameters.AddWithValue("@ShipCountry", (object)orders.ShipCountry ?? DBNull.Value);
                            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;
            }
        }
Example #6
0
        //END - readBy
        //BEGIN - create
        public void AddOrders(OrdersSingle orders)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    BusinessLayer.Validation isdte = new BusinessLayer.Validation();
                    if (isdte.IsDate(orders.OrderDate) == false)
                    {
                        orders.OrderDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    if (isdte.IsDate(orders.RequiredDate) == false)
                    {
                        orders.RequiredDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }

                    if (isdte.IsDate(orders.ShippedDate) == false)
                    {
                        orders.ShippedDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
                    }


                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        SqlCommand cmd = new SqlCommand("spAddOrders", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        };
                        SqlParameter paramOrderID = new SqlParameter
                        {
                            ParameterName = "@OrderID",
                            Value         = orders.OrderID
                        };
                        cmd.Parameters.Add(paramOrderID);

                        SqlParameter paramCustomerID = new SqlParameter
                        {
                            ParameterName = "@CustomerID",
                            Value         = orders.CustomerID
                        };
                        cmd.Parameters.Add(paramCustomerID);

                        SqlParameter paramEmployeeID = new SqlParameter
                        {
                            ParameterName = "@EmployeeID",
                            Value         = orders.EmployeeID
                        };
                        cmd.Parameters.Add(paramEmployeeID);

                        SqlParameter paramOrderDate = new SqlParameter
                        {
                            ParameterName = "@OrderDate",
                            Value         = orders.OrderDate
                        };
                        cmd.Parameters.Add(paramOrderDate);

                        SqlParameter paramRequiredDate = new SqlParameter
                        {
                            ParameterName = "@RequiredDate",
                            Value         = orders.RequiredDate
                        };
                        cmd.Parameters.Add(paramRequiredDate);

                        SqlParameter paramShippedDate = new SqlParameter
                        {
                            ParameterName = "@ShippedDate",
                            Value         = orders.ShippedDate
                        };
                        cmd.Parameters.Add(paramShippedDate);

                        SqlParameter paramShipVia = new SqlParameter
                        {
                            ParameterName = "@ShipVia",
                            Value         = orders.ShipVia
                        };
                        cmd.Parameters.Add(paramShipVia);

                        SqlParameter paramFreight = new SqlParameter
                        {
                            ParameterName = "@Freight",
                            Value         = orders.Freight
                        };
                        cmd.Parameters.Add(paramFreight);

                        SqlParameter paramShipName = new SqlParameter
                        {
                            ParameterName = "@ShipName",
                            Value         = orders.ShipName
                        };
                        cmd.Parameters.Add(paramShipName);

                        SqlParameter paramShipAddress = new SqlParameter
                        {
                            ParameterName = "@ShipAddress",
                            Value         = orders.ShipAddress
                        };
                        cmd.Parameters.Add(paramShipAddress);

                        SqlParameter paramShipCity = new SqlParameter
                        {
                            ParameterName = "@ShipCity",
                            Value         = orders.ShipCity
                        };
                        cmd.Parameters.Add(paramShipCity);

                        SqlParameter paramShipRegion = new SqlParameter
                        {
                            ParameterName = "@ShipRegion",
                            Value         = orders.ShipRegion
                        };
                        cmd.Parameters.Add(paramShipRegion);

                        SqlParameter paramShipPostalCode = new SqlParameter
                        {
                            ParameterName = "@ShipPostalCode",
                            Value         = orders.ShipPostalCode
                        };
                        cmd.Parameters.Add(paramShipPostalCode);

                        SqlParameter paramShipCountry = new SqlParameter
                        {
                            ParameterName = "@ShipCountry",
                            Value         = orders.ShipCountry
                        };
                        cmd.Parameters.Add(paramShipCountry);

                        con.Open();
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();
                    }
                }
                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;
            }
        }