Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have DB Methods(Functions/Stored Procedures).
Different dotnet methods having same db methods(ie., Sp)
How do i combine the different dotnet methods into one?
(Different dotnet methods having different parameters not a same parameter in it for a specific sp/func)
I need to combine the two or more than two dotnet methods into one when the same sp or functions came

My coding is given below

C#
public static int Add_quote_detail(int quote_id, char quote_item_type, int quote_item_id, object contract_template_id, double quantity, object unitprice, object discount, object itemprice,
            object sub_account_no, string notes, object quote_change_detail_id, object quote_item_assignment_level, object parent_quote_detail_id, string source_table, object source_table_id, object unit_list_price,
            object predefined_discount, object predefined_discount_pct, string span_frequency, object frequency_quantity, object rating_type, bool use_list_price, object rating_method, object cam_no, object effective_date,
            object contract_effective_date, bool ratestatus, object slab_value, object UsedContractTemplateId, out string error_msg, string ActivityName = null,string higher_contract_level=null)
        {
            if (notes == "")
                notes = null;
            if (source_table == "")
                source_table = null;
            if (span_frequency == "")
                span_frequency = null;
            object[,] ParameterValue ={{"quote_id",quote_id},{"quote_item_type",quote_item_type},{"quote_item_id",quote_item_id},{"contract_template_id",contract_template_id},{"quantity",quantity},{"unitprice",unitprice},
                                      {"discount",discount},{"itemprice",itemprice},{"sub_account_no",sub_account_no},{"notes",notes},{"quote_change_detail_id",quote_change_detail_id},{"quote_item_assignment_level",quote_item_assignment_level},
                                      {"parent_quote_detail_id",parent_quote_detail_id},{"source_table",source_table},{"source_table_id",source_table_id},{"unit_list_price",unit_list_price},{"predefined_discount",predefined_discount},
                                      {"predefined_discount_pct",predefined_discount_pct},{"span_frequency",span_frequency},{"frequency_quantity",frequency_quantity},{"rating_type",rating_type},{"use_list_price",use_list_price},
                                      {"rating_method",rating_method},{"cam_no",cam_no},{"effective_date",effective_date},{"contract_effective_date",contract_effective_date},{"ratestatus",ratestatus},{"slab_value",slab_value},
                                      {"activity_name","AddProduct"},{"used_contract_template_id",UsedContractTemplateId},{"higher_contract_level",higher_contract_level}};
            //return Convert.ToInt32(DataUtils_CRM_Engine.GetValue("CRM.spI_quote_detail", ParameterValue, true));
            return DBIUtis.FetchScalar<int>(GetConnection(), "CRM.spI_quote_detail", out error_msg, ParameterValue, CommandType.StoredProcedure);
        }


 public static void Add_Service(int QuoteId, int quote_item_id, double quantity, object unitprice, object discount, object itemprice, object PV_Sub_AccNo, bool list_price, string activity_name, out string Result)
        {
            object[,] parametervalue = { {"quote_id", QuoteId }, { "quote_item_type", "S" }, { "quote_item_id", quote_item_id }, 
                                       { "contract_template_id",DBNull.Value }, { "quantity",quantity }, { "unitprice",unitprice }, 
                                       { "discount",discount },{ "itemprice",itemprice }, { "sub_account_no",PV_Sub_AccNo }, 
                                    { "notes",null }, { "quote_change_detail_id",null },{"use_list_price",list_price},{"activity_name",activity_name}};

            if (DBIUtis.ExecuteSP(GetConnection(), "crm.spI_quote_detail", ref parametervalue, out ReturnValue, out ErrorMessage) != 0)
                Result = ErrorMessage;
            else
                Result = "Service Added Successfully";

        }


Note:
Both the above two dotnet methods utilizing crm.spI_quote_detail
Posted
Updated 1-Sep-14 2:41am
v2

1 solution

Create new class that will be your quote
Public Class QuoteItem
public property int QuoteId;
public property int QuoteItemId;
etc...

and then call
add_quote_details (QuoteItem qi)

and

Add_Service (QuoteItem qi)

using whatever properties you need for them or simply using one of them.


Of course, you need to take care of filling the object, but at the moment you're calling these functions you obviously have everything you need so just create and fill the object before calling the functions if there is no other obvious place for it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900