当相同的sp或函数出现时,需要将两个或两个以上的dotnet方法合并为一个 [英] Need to combine the two or more than two dotnet methods into one when the same sp or functions came

查看:97
本文介绍了当相同的sp或函数出现时,需要将两个或两个以上的dotnet方法合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有DB方法(函数/存储过程)。

具有相同db方法的不同dotnet方法(即,Sp)

如何组合不同的dotnet方法合二为一?

(不同的dotnet方法具有不同的参数,对于特定的sp / func,它们的参数不同)

我需要将两个或两个以上的组合起来当相同的sp或函数出现时,dotnet方法合为一个



我的编码如下:



  public   static   int  Add_quote_detail( int  quote_id, char  quote_item_type, int  quote_item_id, object  contract_template_id, double 数量, object  unitprice,对象 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,对象 unit_list_price,
对象 predefined_discount,对象 predefined_discount_pct, string span_frequency, object frequency_quantity, object rating_type,< span class =code-keyword> 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},{ < span class =code-string> 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},{< span class =code-string> 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}};
// 返回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 数量,对象 unitprice,对象折扣,< span class =code-keyword> object
itemprice, object PV_Sub_AccNo, bool list_price, string activity_name, out string 结果)
{
object [,] parametervalue = {{ quote_id,QuoteId},{ quote_item_type S},{ quote_item_id,quote_item_id},
{ contract_template_id,DBNull.Value},{ 数量,数量},{ unitprice,unitprice},
{ discount,discount},{ itemprice,itemprice},{ sub_account_no,PV_Sub_AccNo},
{ notes null },{ quote_change_detail_id null },{ use_list_price,list_price},{ < span class =code-string> activity_name,activity_name}};

if (DBIUtis.ExecuteSP(GetConnection(), crm.spI_quote_detail ref parametervalue, out ReturnValue, out ErrorMessage)!= 0
Result = ErrorMessage;
else
结果= 服务成功添加;

}





注:

以上两种使用crm的dotnet方法.spI_quote_detail

解决方案

创建将作为您报价的新类

公共类QuoteItem

公共属性int QuoteId ;

公共财产int QuoteItemId;

等...



再拨打

add_quote_details(QuoteItem qi)







Add_Service(QuoteItem qi)



使用您需要的任何属性或只使用其中一个属性。





当然,你需要注意填充对象,但是当你调用这些函数时,你显然拥有了你需要的所有东西,所以如果没有其他明显的位置,只需在调用函数之前创建并填充对象。

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

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

解决方案

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.


这篇关于当相同的sp或函数出现时,需要将两个或两个以上的dotnet方法合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆