Exemplo n.º 1
0
    public static dbo_ReceiveDetailClass Select_Record(dbo_ReceiveDetailClass clsdbo_ReceiveDetailPara)
    {
        dbo_ReceiveDetailClass clsdbo_ReceiveDetail = new dbo_ReceiveDetailClass();
        SqlConnection          connection           = SAMDataClass.GetConnection();
        string     selectProcedure = "[dbo].[ReceiveDetailSelect]";
        SqlCommand selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@Billing_Detail_ID", clsdbo_ReceiveDetailPara.Billing_Detail_ID);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_ReceiveDetail.Receive_Detail_ID = reader["Receive_Detail_ID"] is DBNull ? null : reader["Receive_Detail_ID"].ToString();
                clsdbo_ReceiveDetail.Billing_Detail_ID = reader["Billing_Detail_ID"] is DBNull ? null : reader["Billing_Detail_ID"].ToString();
                clsdbo_ReceiveDetail.Material_No       = reader["Material_No"] is DBNull ? null : reader["Material_No"].ToString();
                clsdbo_ReceiveDetail.Qty       = reader["Qty"] is DBNull ? null : (Int16?)reader["Qty"];
                clsdbo_ReceiveDetail.UOM       = reader["UOM"] is DBNull ? null : reader["UOM"].ToString();
                clsdbo_ReceiveDetail.Net_Value = reader["Net_Value"] is DBNull ? null : (Decimal?)reader["Net_Value"];
                clsdbo_ReceiveDetail.Vat       = reader["Vat"] is DBNull ? null : (Decimal?)reader["Vat"];
                clsdbo_ReceiveDetail.Total     = reader["Total"] is DBNull ? null : (Decimal?)reader["Total"];
            }
            else
            {
                clsdbo_ReceiveDetail = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_ReceiveDetail);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_ReceiveDetail);
    }
Exemplo n.º 2
0
    public static bool Delete(dbo_ReceiveDetailClass clsdbo_ReceiveDetail)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[dbo].[ReceiveDetailDelete]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_ReceiveDetail.Receive_Detail_ID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldReceive_Detail_ID", clsdbo_ReceiveDetail.Receive_Detail_ID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldReceive_Detail_ID", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Billing_Detail_ID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldBilling_Detail_ID", clsdbo_ReceiveDetail.Billing_Detail_ID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldBilling_Detail_ID", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Material_No != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldMaterial_No", clsdbo_ReceiveDetail.Material_No);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldMaterial_No", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Qty.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldQty", clsdbo_ReceiveDetail.Qty);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldQty", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.UOM != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldUOM", clsdbo_ReceiveDetail.UOM);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldUOM", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Net_Value.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldNet_Value", clsdbo_ReceiveDetail.Net_Value);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldNet_Value", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Vat.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldVat", clsdbo_ReceiveDetail.Vat);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldVat", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Total.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldTotal", clsdbo_ReceiveDetail.Total);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldTotal", DBNull.Value);
        }
        deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            deleteCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
Exemplo n.º 3
0
    public static bool Add(dbo_ReceiveDetailClass clsdbo_ReceiveDetail, String Created_By)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "ReceiveDetailInsert";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_ReceiveDetail.Receive_Detail_ID != null)
        {
            insertCommand.Parameters.AddWithValue("@Receive_Detail_ID", clsdbo_ReceiveDetail.Receive_Detail_ID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Receive_Detail_ID", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Billing_Detail_ID != null)
        {
            insertCommand.Parameters.AddWithValue("@Billing_Detail_ID", clsdbo_ReceiveDetail.Billing_Detail_ID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Billing_Detail_ID", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Material_No != null)
        {
            insertCommand.Parameters.AddWithValue("@Material_No", clsdbo_ReceiveDetail.Material_No);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Material_No", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Qty.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Qty", clsdbo_ReceiveDetail.Qty);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Qty", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.UOM != null)
        {
            insertCommand.Parameters.AddWithValue("@UOM", clsdbo_ReceiveDetail.UOM);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@UOM", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Net_Value.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Net_Value", clsdbo_ReceiveDetail.Net_Value);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Net_Value", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Vat.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Vat", clsdbo_ReceiveDetail.Vat);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Vat", DBNull.Value);
        }
        if (clsdbo_ReceiveDetail.Total.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Total", clsdbo_ReceiveDetail.Total);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Total", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Created_By))
        {
            insertCommand.Parameters.AddWithValue("@Created_By", Created_By);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Created_By", DBNull.Value);
        }
        insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
        insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
        try
        {
            connection.Open();
            insertCommand.ExecuteNonQuery();
            int count = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value);
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }