示例#1
0
    public static dbo_ReceiveClass Select_Record(dbo_ReceiveClass clsdbo_ReceivePara)
    {
        dbo_ReceiveClass clsdbo_Receive  = new dbo_ReceiveClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "[dbo].[ReceiveSelect]";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;
        selectCommand.Parameters.AddWithValue("@Invoice_No", clsdbo_ReceivePara.Invoice_No);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsdbo_Receive.Receive_ID        = reader["Receive_ID"] is DBNull ? null : reader["Receive_ID"].ToString();
                clsdbo_Receive.Billing_ID        = reader["Billing_ID"] is DBNull ? null : reader["Billing_ID"].ToString();
                clsdbo_Receive.Invoice_No        = reader["Invoice_No"] is DBNull ? null : reader["Invoice_No"].ToString();
                clsdbo_Receive.Invoice_Date      = reader["Invoice_Date"] is DBNull ? null : (DateTime?)reader["Invoice_Date"];
                clsdbo_Receive.Invoice_Net_Value = reader["Invoice_Net_Value"] is DBNull ? null : (Decimal?)reader["Invoice_Net_Value"];
                clsdbo_Receive.Invoice_VAT       = reader["Invoice_VAT"] is DBNull ? null : (Decimal?)reader["Invoice_VAT"];
                clsdbo_Receive.Invoice_Total     = reader["Invoice_Total"] is DBNull ? null : (Decimal?)reader["Invoice_Total"];
                clsdbo_Receive.Ref_Invoice_No    = reader["Ref_Invoice_No"] is DBNull ? null : reader["Ref_Invoice_No"].ToString();
            }
            else
            {
                clsdbo_Receive = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(clsdbo_Receive);
        }
        finally
        {
            connection.Close();
        }
        return(clsdbo_Receive);
    }
示例#2
0
    public static bool Delete(dbo_ReceiveClass clsdbo_Receive)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        deleteProcedure = "[dbo].[ReceiveDelete]";
        SqlCommand    deleteCommand   = new SqlCommand(deleteProcedure, connection);

        deleteCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_Receive.Receive_ID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldReceive_ID", clsdbo_Receive.Receive_ID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldReceive_ID", DBNull.Value);
        }
        if (clsdbo_Receive.Billing_ID != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldBilling_ID", clsdbo_Receive.Billing_ID);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldBilling_ID", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_No != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_No", clsdbo_Receive.Invoice_No);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_No", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_Date.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_Date", clsdbo_Receive.Invoice_Date);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_Date", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_Net_Value.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_Net_Value", clsdbo_Receive.Invoice_Net_Value);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_Net_Value", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_VAT.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_VAT", clsdbo_Receive.Invoice_VAT);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_VAT", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_Total.HasValue == true)
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_Total", clsdbo_Receive.Invoice_Total);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldInvoice_Total", DBNull.Value);
        }
        if (clsdbo_Receive.Ref_Invoice_No != null)
        {
            deleteCommand.Parameters.AddWithValue("@OldRef_Invoice_No", clsdbo_Receive.Ref_Invoice_No);
        }
        else
        {
            deleteCommand.Parameters.AddWithValue("@OldRef_Invoice_No", 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();
        }
    }
示例#3
0
    public static bool Add(dbo_ReceiveClass clsdbo_Receive, String Created_By)
    {
        logger.Info(System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value == null ? string.Empty : System.Web.HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "[ReceiveInsert]";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        if (clsdbo_Receive.Receive_ID != null)
        {
            insertCommand.Parameters.AddWithValue("@Receive_ID", clsdbo_Receive.Receive_ID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Receive_ID", DBNull.Value);
        }
        if (clsdbo_Receive.Billing_ID != null)
        {
            insertCommand.Parameters.AddWithValue("@Billing_ID", clsdbo_Receive.Billing_ID);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Billing_ID", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_No != null)
        {
            insertCommand.Parameters.AddWithValue("@Invoice_No", clsdbo_Receive.Invoice_No);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Invoice_No", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_Date.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Invoice_Date", clsdbo_Receive.Invoice_Date);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Invoice_Date", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_Net_Value.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Invoice_Net_Value", clsdbo_Receive.Invoice_Net_Value);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Invoice_Net_Value", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_VAT.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Invoice_VAT", clsdbo_Receive.Invoice_VAT);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Invoice_VAT", DBNull.Value);
        }
        if (clsdbo_Receive.Invoice_Total.HasValue == true)
        {
            insertCommand.Parameters.AddWithValue("@Invoice_Total", clsdbo_Receive.Invoice_Total);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Invoice_Total", DBNull.Value);
        }
        if (clsdbo_Receive.Ref_Invoice_No != null)
        {
            insertCommand.Parameters.AddWithValue("@Ref_Invoice_No", clsdbo_Receive.Ref_Invoice_No);
        }
        else
        {
            insertCommand.Parameters.AddWithValue("@Ref_Invoice_No", 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();
        }
    }