public static bool InsertCustomer(Customer c)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Name", SqlDbType.NVarChar)
                    {
                        Value = c.CustomerName
                    },
                    new SqlParameter("@Surname", SqlDbType.NVarChar)
                    {
                        Value = c.CustomerSurname
                    },
                    new SqlParameter("@Number", SqlDbType.NVarChar)
                    {
                        Value = c.CustomerPhone
                    },

                    new SqlParameter("@IdCustomer", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.ReturnValue
                    }
                };

                SQLHelper.ExecuteScalar(GlobalVars.DBConn, CommandType.StoredProcedure, "[dbo].[InsertCustomer]", parameters);
                c.IdCustomer = Convertions.ParseToIntOrZero(parameters[3].Value.ToString());
                return(Convertions.ParseToValidBoolean(c.IdCustomer.ToString()));
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public static bool InsertType(Type t)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Name_Type", SqlDbType.NVarChar)
                    {
                        Value = t.NameType
                    },
                    new SqlParameter("@Code_Type", SqlDbType.NVarChar)
                    {
                        Value = t.CodeType
                    },

                    new SqlParameter("@IdType", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.ReturnValue
                    }
                };

                SQLHelper.ExecuteScalar(GlobalVars.DBConn, CommandType.StoredProcedure, "[dbo].[InsertType]", parameters);
                t.IdType = Convertions.ParseToIntOrZero(parameters[2].Value.ToString());
                return(Convertions.ParseToValidBoolean(t.IdType.ToString()));
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public static bool InsertOperation(Operation o)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Date_Start", SqlDbType.DateTime)
                    {
                        Value = o.DateStart
                    },
                    new SqlParameter("@Date_End", SqlDbType.DateTime)
                    {
                        Value = o.DateEnd
                    },
                    new SqlParameter("@ID_Type", SqlDbType.Int)
                    {
                        Value = o.IDType
                    },
                    new SqlParameter("@ID_Packets", SqlDbType.Int)
                    {
                        Value = o.IDPackets
                    },
                    new SqlParameter("@ID_Driver", SqlDbType.Int)
                    {
                        Value = o.IDDriver
                    },

                    new SqlParameter("@Destination", SqlDbType.NVarChar)
                    {
                        Value = o.Destination
                    },


                    new SqlParameter("@IdOperation", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.ReturnValue
                    }
                };

                SQLHelper.ExecuteScalar(GlobalVars.DBConn, CommandType.StoredProcedure, "[dbo].[InsertOperation]", parameters);
                o.IdOperation = Convertions.ParseToIntOrZero(parameters[6].Value.ToString());
                return(Convertions.ParseToValidBoolean(o.IdOperation.ToString()));
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        public static bool InsertProduct(Product p)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Number_of_Peaces", SqlDbType.NVarChar)
                    {
                        Value = p.NumberOfPeaces
                    },
                    new SqlParameter("@Size_of_Peaces", SqlDbType.NVarChar)
                    {
                        Value = p.SizeOfPeaces
                    },
                    new SqlParameter("@ID_Customer", SqlDbType.Int)
                    {
                        Value = p.IdCustomer
                    },
                    new SqlParameter("@Total_Weight", SqlDbType.NVarChar)
                    {
                        Value = p.TotalWeight
                    },

                    new SqlParameter("@IdPackets", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.ReturnValue
                    }
                };

                SQLHelper.ExecuteScalar(GlobalVars.DBConn, CommandType.StoredProcedure, "[dbo].[InsertProduct]", parameters);
                p.IdPackets = Convertions.ParseToIntOrZero(parameters[4].Value.ToString());
                return(Convertions.ParseToValidBoolean(p.IdPackets.ToString()));
            }
            catch (Exception e)
            {
                return(false);
            }
        }