コード例 #1
0
    public static dbo_DepositClass SumNetSalesBySPID(String User_ID)
    {
        dbo_DepositClass clsdbo_Deposit  = new dbo_DepositClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "[DepositSumNetSalesBySP]";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@User_ID", User_ID);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_Deposit.Net_Sales_Amount = reader["Net_Sales_Amount"] is DBNull ? null : (Decimal?)reader["Net_Sales_Amount"];
            }
            else
            {
                clsdbo_Deposit = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_Deposit);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_Deposit);
    }
コード例 #2
0
    public static dbo_DepositClass Select_Record(String Clearing_No)
    {
        dbo_DepositClass clsdbo_Deposit  = new dbo_DepositClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "[DepositSelect]";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@Clearing_No", Clearing_No);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_Deposit.Clearing_No      = reader["Clearing_No"] is DBNull ? null : reader["Clearing_No"].ToString();
                clsdbo_Deposit.Net_Sales_Qty    = reader["Net_Sales_Qty"] is DBNull ? null : (Int16?)reader["Net_Sales_Qty"];
                clsdbo_Deposit.Net_Sales_Amount = reader["Net_Sales_Amount"] is DBNull ? null : (Decimal?)reader["Net_Sales_Amount"];
                clsdbo_Deposit.Total_Commission = reader["Total_Commission"] is DBNull ? null : (Decimal?)reader["Total_Commission"];
                clsdbo_Deposit.Tota_Point       = reader["Tota_Point"] is DBNull ? null : (Int16?)reader["Tota_Point"];
            }
            else
            {
                clsdbo_Deposit = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_Deposit);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_Deposit);
    }
コード例 #3
0
    public static bool Update(dbo_DepositClass newdbo_DepositClass)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        updateProcedure = "[DepositUpdate]";
        SqlCommand    updateCommand   = new SqlCommand(updateProcedure, connection);

        updateCommand.CommandType = CommandType.StoredProcedure;
        if (newdbo_DepositClass.Clearing_No != null)
        {
            updateCommand.Parameters.AddWithValue("@NewClearing_No", newdbo_DepositClass.Clearing_No);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewClearing_No", DBNull.Value);
        }
        if (newdbo_DepositClass.Net_Sales_Qty.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewNet_Sales_Qty", newdbo_DepositClass.Net_Sales_Qty);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewNet_Sales_Qty", DBNull.Value);
        }
        if (newdbo_DepositClass.Net_Sales_Amount.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewNet_Sales_Amount", newdbo_DepositClass.Net_Sales_Amount);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewNet_Sales_Amount", DBNull.Value);
        }
        if (newdbo_DepositClass.Total_Commission.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewTotal_Commission", newdbo_DepositClass.Total_Commission);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewTotal_Commission", DBNull.Value);
        }
        if (newdbo_DepositClass.Tota_Point.HasValue == true)
        {
            updateCommand.Parameters.AddWithValue("@NewTota_Point", newdbo_DepositClass.Tota_Point);
        }
        else
        {
            updateCommand.Parameters.AddWithValue("@NewTota_Point", DBNull.Value);
        }


        updateCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        updateCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            updateCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(updateCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }