public int UpdateCustomerInquiry(InquiryBDto inquiry) { Database db = null; DbCommand dbCmd = null; int Result = 0; try { db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING); dbCmd = db.GetStoredProcCommand(DALHelper.USP_CUST_CUSTOMER_INQURIES_UPDATE); db.AddInParameter(dbCmd, "@INQUIRY_NO", DbType.Int32, inquiry.InquiryNo); db.AddInParameter(dbCmd, "@CUST_ID", DbType.Int32, inquiry.CustomerId); db.AddInParameter(dbCmd, "@CUST_REL_ID", DbType.Int32, inquiry.CustomerRelationId); db.AddInParameter(dbCmd, "@CUST_REL_SRNO", DbType.Int32, inquiry.CustomerRelationSerialNo); db.AddInParameter(dbCmd, "@INQUIRY_FOR", DbType.Int32, inquiry.InquiryForId); if (!String.IsNullOrEmpty(inquiry.InquiryDescription)) db.AddInParameter(dbCmd, "@INQUIRY_DESC", DbType.String, inquiry.InquiryDescription); else db.AddInParameter(dbCmd, "@INQUIRY_DESC", DbType.String, DBNull.Value); if (inquiry.InquiryDate != DateTime.MinValue) db.AddInParameter(dbCmd, "@INQUIRY_DATE", DbType.DateTime, inquiry.InquiryDate); else db.AddInParameter(dbCmd, "@INQUIRY_DATE", DbType.DateTime, DBNull.Value); if (inquiry.ReferenceId != 0) db.AddInParameter(dbCmd, "@REFERENCE_ID", DbType.Int32, inquiry.ReferenceId); else db.AddInParameter(dbCmd, "@REFERENCE_ID", DbType.Int32, DBNull.Value); if (inquiry.CustomerReferenceId != 0) db.AddInParameter(dbCmd, "@CUST_REFERENCE_ID", DbType.Int32, inquiry.CustomerReferenceId); else db.AddInParameter(dbCmd, "@CUST_REFERENCE_ID", DbType.Int32, DBNull.Value); if (inquiry.SalesPersonId != 0) db.AddInParameter(dbCmd, "@SALES_PERSON_ID", DbType.Int32, inquiry.SalesPersonId); else db.AddInParameter(dbCmd, "@SALES_PERSON_ID", DbType.Int32, DBNull.Value); if (inquiry.InquiryModeId != 0) db.AddInParameter(dbCmd, "@INQUIRY_MODE", DbType.Int32, inquiry.InquiryModeId); else db.AddInParameter(dbCmd, "@INQUIRY_MODE", DbType.Int32, DBNull.Value); if (inquiry.NextFollowupDate != DateTime.MinValue) db.AddInParameter(dbCmd, "@NEXT_FOLLOWUP_DATE", DbType.DateTime, inquiry.NextFollowupDate); else db.AddInParameter(dbCmd, "@NEXT_FOLLOWUP_DATE", DbType.DateTime, DBNull.Value); if (!String.IsNullOrEmpty(inquiry.InternalRemarks)) db.AddInParameter(dbCmd, "@INTERNAL_REMARKS", DbType.String, inquiry.InternalRemarks); else db.AddInParameter(dbCmd, "@INTERNAL_REMARKS", DbType.String, DBNull.Value); if (inquiry.InquiryStatusId != 0) db.AddInParameter(dbCmd, "@INQUIRY_STATUS", DbType.Int32, inquiry.InquiryStatusId); else db.AddInParameter(dbCmd, "@INQUIRY_STATUS", DbType.Int32, DBNull.Value); if (inquiry.CurrentInquiryStatusId != 0) db.AddInParameter(dbCmd, "@CURRENT_INQUIRY_STATUS", DbType.Int32, inquiry.CurrentInquiryStatusId); else db.AddInParameter(dbCmd, "@CURRENT_INQUIRY_STATUS", DbType.Int32, DBNull.Value); if (inquiry.OwnerCompanyId != 0) db.AddInParameter(dbCmd, "@OWNER_COMPANY_ID", DbType.Int32, inquiry.OwnerCompanyId); else db.AddInParameter(dbCmd, "@OWNER_COMPANY_ID", DbType.Int32, DBNull.Value); db.AddInParameter(dbCmd, "@USER_ID", DbType.Int32, inquiry.UserId); db.AddOutParameter(dbCmd, "@IS_INSERT", DbType.Int32, 1); db.ExecuteNonQuery(dbCmd); Result = Convert.ToInt32(db.GetParameterValue(dbCmd, "@IS_INSERT")); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } finally { DALHelper.Destroy(ref dbCmd); } return Result; }
public DataSet GetCustomerInquries(CustomerBDto customer, InquiryBDto inquiry) { Database db = null; DbCommand dbCmd = null; DataSet ds = null; try { db = DatabaseFactory.CreateDatabase(DALHelper.CRM_CONNECTION_STRING); dbCmd = db.GetStoredProcCommand(DALHelper.USP_CUST_CUSTOMER_INQURIES_SELECT); if (!String.IsNullOrEmpty(customer.SurName)) db.AddInParameter(dbCmd, "@SURNAME", DbType.String, customer.SurName); else db.AddInParameter(dbCmd, "@SURNAME", DbType.String, DBNull.Value); if (!String.IsNullOrEmpty(customer.UniqueId)) db.AddInParameter(dbCmd, "@UNIQUE_ID", DbType.String, customer.UniqueId); else db.AddInParameter(dbCmd, "@UNIQUE_ID", DbType.String, DBNull.Value); if (!String.IsNullOrEmpty(customer.Name)) db.AddInParameter(dbCmd, "@NAME", DbType.String, customer.Name); else db.AddInParameter(dbCmd, "@NAME", DbType.String, DBNull.Value); if (!String.IsNullOrEmpty(customer.ContactInfo.EmailId)) db.AddInParameter(dbCmd, "@EMAIL", DbType.String, customer.ContactInfo.EmailId); else db.AddInParameter(dbCmd, "@EMAIL", DbType.String, DBNull.Value); if (!String.IsNullOrEmpty(customer.ContactInfo.MobileNo)) db.AddInParameter(dbCmd, "@MOBILE", DbType.String, customer.ContactInfo.MobileNo); else db.AddInParameter(dbCmd, "@MOBILE", DbType.String, DBNull.Value); if (!String.IsNullOrEmpty(customer.ContactInfo.PhoneNo)) db.AddInParameter(dbCmd, "@PHONE", DbType.String, customer.ContactInfo.PhoneNo); else db.AddInParameter(dbCmd, "@PHONE", DbType.String, DBNull.Value); if (!String.IsNullOrEmpty(customer.CompanyName)) db.AddInParameter(dbCmd, "@COMPANY", DbType.String, customer.CompanyName); else db.AddInParameter(dbCmd, "@COMPANY", DbType.String, DBNull.Value); if (customer.ProfessionId != 0) db.AddInParameter(dbCmd, "@PROFESSION_ID", DbType.Int32, customer.ProfessionId); else db.AddInParameter(dbCmd, "@PROFESSION_ID", DbType.Int32, DBNull.Value); if (!String.IsNullOrEmpty(customer.PassPortInfo.PassportNo)) db.AddInParameter(dbCmd, "@PASSPORT_NO", DbType.String, customer.PassPortInfo.PassportNo); else db.AddInParameter(dbCmd, "@PASSPORT_NO", DbType.String, DBNull.Value); if (customer.AddressInfo.AddressTypeId != 0) db.AddInParameter(dbCmd, "@ADDRESS_TYPE_ID", DbType.Int32, customer.AddressInfo.AddressTypeId); else db.AddInParameter(dbCmd, "@ADDRESS_TYPE_ID", DbType.Int32, DBNull.Value); if (!String.IsNullOrEmpty(customer.AddressInfo.AddressLine1)) db.AddInParameter(dbCmd, "@ADDRESS_LINE1", DbType.String, customer.AddressInfo.AddressLine1); else db.AddInParameter(dbCmd, "@ADDRESS_LINE1", DbType.String, DBNull.Value); if (!String.IsNullOrEmpty(customer.AddressInfo.AddressLine2)) db.AddInParameter(dbCmd, "@ADDRESS_LINE2", DbType.String, customer.AddressInfo.AddressLine2); else db.AddInParameter(dbCmd, "@ADDRESS_LINE2", DbType.String, DBNull.Value); if (customer.AddressInfo.CityId != 0) db.AddInParameter(dbCmd, "@CITY_ID", DbType.Int32, customer.AddressInfo.CityId); else db.AddInParameter(dbCmd, "@CITY_ID", DbType.Int32, DBNull.Value); if (customer.AddressInfo.StateId != 0) db.AddInParameter(dbCmd, "@STATE_ID", DbType.Int32, customer.AddressInfo.StateId); else db.AddInParameter(dbCmd, "@STATE_ID", DbType.Int32, DBNull.Value); if (customer.AddressInfo.CountryId != 0) db.AddInParameter(dbCmd, "@COUNTRY_ID", DbType.Int32, customer.AddressInfo.CountryId); else db.AddInParameter(dbCmd, "@COUNTRY_ID", DbType.Int32, DBNull.Value); if (inquiry.InquiryNo != 0) db.AddInParameter(dbCmd, "@INQUIRY_NO", DbType.Int32, inquiry.InquiryNo); else db.AddInParameter(dbCmd, "@INQUIRY_NO", DbType.Int32, DBNull.Value); if (inquiry.InquiryForId != 0) db.AddInParameter(dbCmd, "@INQUIRY_FOR", DbType.Int32, inquiry.InquiryForId); else db.AddInParameter(dbCmd, "@INQUIRY_FOR", DbType.Int32, DBNull.Value); if (!String.IsNullOrEmpty(inquiry.InquiryDescription)) db.AddInParameter(dbCmd, "@INQUIRY_DESC", DbType.String, inquiry.InquiryDescription); else db.AddInParameter(dbCmd, "@INQUIRY_DESC", DbType.String, DBNull.Value); if (inquiry.InquiryStatusId != 0) db.AddInParameter(dbCmd, "@INQUIRY_STATUS", DbType.Int32, inquiry.InquiryStatusId); else db.AddInParameter(dbCmd, "@INQUIRY_STATUS", DbType.Int32, DBNull.Value); if (inquiry.InquiryDate != DateTime.MinValue) db.AddInParameter(dbCmd, "@INQUIRY_DATE_FROM", DbType.DateTime, inquiry.InquiryDate); else db.AddInParameter(dbCmd, "@INQUIRY_DATE_FROM", DbType.DateTime, DBNull.Value); if (inquiry.NextFollowupDate != DateTime.MinValue) db.AddInParameter(dbCmd, "@INQUIRY_DATE_TO", DbType.DateTime, inquiry.NextFollowupDate); else db.AddInParameter(dbCmd, "@INQUIRY_DATE_TO", DbType.DateTime, DBNull.Value); if (inquiry.SalesPersonId != 0) db.AddInParameter(dbCmd, "@SALES_PERSON_ID", DbType.Int32, inquiry.SalesPersonId); else db.AddInParameter(dbCmd, "@SALES_PERSON_ID", DbType.Int32, DBNull.Value); if (inquiry.OwnerCompanyId != 0) db.AddInParameter(dbCmd, "@OWNER_COMPANY_ID", DbType.Int32, inquiry.OwnerCompanyId); else db.AddInParameter(dbCmd, "@OWNER_COMPANY_ID", DbType.Int32, DBNull.Value); ds = db.ExecuteDataSet(dbCmd); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME); if (rethrow) { throw ex; } } finally { DALHelper.Destroy(ref dbCmd); } return ds; }