public Int64 Insert(productimagesvideos objproductimagesvideos)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "productimagesvideos_Insert";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@piid";
                param.Value         = objproductimagesvideos.piid;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@pid", objproductimagesvideos.pid);
                cmd.Parameters.AddWithValue("@type", objproductimagesvideos.type);
                cmd.Parameters.AddWithValue("@imagevideoname", objproductimagesvideos.imagevideoname);
                cmd.Parameters.AddWithValue("@imagevideopath", objproductimagesvideos.imagevideopath);

                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
        public DataTable SelectAll(productimagesvideos objproductimagesvideos)
        {
            DataSet        ds = new DataSet();
            SqlDataAdapter da;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "productimagesvideos_SelectAll";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;


                #region Null checking
                if (objproductimagesvideos.piid != 0 && objproductimagesvideos.piid != null)
                {
                    cmd.Parameters.AddWithValue("@piid", objproductimagesvideos.piid);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@piid", DBNull.Value);
                }

                if (objproductimagesvideos.pid != 0 && objproductimagesvideos.pid != null)
                {
                    cmd.Parameters.AddWithValue("@pid", objproductimagesvideos.pid);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@pid", DBNull.Value);
                }

                if (objproductimagesvideos.type != 0 && objproductimagesvideos.type != null)
                {
                    cmd.Parameters.AddWithValue("@type", objproductimagesvideos.type);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@type", DBNull.Value);
                }

                if (objproductimagesvideos.imagevideoname != "" && objproductimagesvideos.imagevideoname != null)
                {
                    cmd.Parameters.AddWithValue("@imagevideoname", objproductimagesvideos.imagevideoname);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@imagevideoname", DBNull.Value);
                }

                if (objproductimagesvideos.imagevideopath != "" && objproductimagesvideos.imagevideopath != null)
                {
                    cmd.Parameters.AddWithValue("@imagevideopath", objproductimagesvideos.imagevideopath);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@imagevideopath", DBNull.Value);
                }

                if (objproductimagesvideos.isdelete != null)
                {
                    cmd.Parameters.AddWithValue("@isdelete", objproductimagesvideos.isdelete);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@isdelete", DBNull.Value);
                }
                #endregion

                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(ds.Tables[0]);
        }