Beispiel #1
0
        public CustomerDetails GetCustomerDetails(int customerNo)
        {
            CustomerDetails custDetails = new CustomerDetails();
            try
            {
                StringBuilder query = new StringBuilder();
                query.Append("  SELECT pty.seq_party_id,");
                query.Append(" eh.seq_element_type_id,");
                query.Append(" pty.party_code,");
                query.Append(" pty.party_name,");
                query.Append(" pty.first_name,");
                query.Append(" pty.last_name,");
                query.Append(" pty.initials,");
                query.Append(" pty.phone_no,");
                query.Append(" pty.std_code,");
                query.Append(" pty.fax_no,");
                query.Append(" pty.email_address,");
                query.Append(" pty.web_address,");
                query.Append(" pty.street_addr_no,");
                query.Append(" pty.street_post_code,");
                query.Append(" pty.postal_post_code,");
                query.Append(" pty.street_addr_1,");
                query.Append(" pty.street_addr_2,");
                query.Append(" pty.street_addr_3,");
                query.Append(" pty.street_addr_4,");
                query.Append(" pty.street_addr_5,");
                query.Append(" pty.postal_addr_1,");
                query.Append(" pty.postal_addr_2,");
                query.Append(" pty.postal_addr_3,");
                query.Append(" pty.postal_addr_4,");
                query.Append("pty.postal_addr_5,");
                query.Append("pty.notes,");
                query.Append(" pty.active,");
                query.Append(" pty.insert_datetime,");
                query.Append(" pty.insert_user,");
                query.Append(" pty.insert_process,");
                query.Append(" pty.update_datetime,");
                query.Append(" pty.update_user,");
                query.Append(" pty.update_process,");
                query.Append(" eh.element_id,");
                query.Append(" eh.element_struct_code,");
                query.Append(" eh.parent_id,");
                query.Append(" eh.parent_element_struct_code,");
                query.Append(" cli.seq_comp_type_id,");
                query.Append(" cli.seq_industry_id,");
                query.Append(" cli.seq_client_priority_id,");

                // Pay method
                query.Append(" cli.seq_pay_method_id,");

                //Billing cycle
                query.Append(" cli.seq_bill_cycle_id,");

                // Credit check id
                query.Append(" cli.seq_int_crd_chk_id,");

                // Delivery mode id
                query.Append(" cli.seq_inv_del_mode_id,");

                // Invoice style id
                query.Append(" cli.seq_inv_style_id,");

                // Tax indicator id
                query.Append(" cli.seq_tax_ind_id,");
                query.Append(" cli.password,");
                query.Append(" cli.employer,");
                query.Append(" cli.alert,");
                query.Append(" cli.estimate_date,");
                query.Append(" cli.auck_employ,");
                query.Append(" cli.nz_employ,");
                query.Append(" cli.annual_sale,");
                query.Append(" cli.mobile_user,");
                query.Append("cli.connect_call,");
                query.Append(" cli.credit_reseller_flag,");
                query.Append(" cli.date_received,");
                query.Append("cli.seq_staff_id,");
                query.Append("cli.credit_limit,");
                query.Append("cli.stop_credit_flag,");
                query.Append(" cli.bank,");
                query.Append(" cli.bank_branch,");
                query.Append(" cli.bank_account_no,");
                query.Append(" cli.credit_card_type_code,");
                query.Append(" cli.credit_card_name,");
                query.Append(" cli.credit_card_no,");
                query.Append(" cli.credit_card_expiry,");
                query.Append(" cli.credit_card_verif_no,");
                query.Append(" cli.prompt_payment_discount,");
                query.Append(" cli.bill_notes,");
                query.Append(" cli.avg_monthly_spend,");
                query.Append(" stf.party_code,");
                query.Append(" stf.party_name,");
                query.Append(" ind.industry_code,");
                query.Append(" ind.industry_desc,");
                query.Append(" override_name = 'N',");
                query.Append(" cli.additional_svce_0800,");
                query.Append(" cli.additional_svce_ccard,");
                query.Append(" cli.additional_svce_power,");
                query.Append(" cli.additional_svce_tolls,");
                query.Append(" cli.seq_pcms_int_status_id,");
                query.Append(" cli.calling_card_reseller,");

                // Credit status id
                query.Append(" cli.seq_credit_status_id,");
                query.Append(" cli.bond,");
                query.Append(" cli.developer,");
                query.Append(" cli.alert_expires,");
                query.Append(" cli.alert_expiry_date,");
                query.Append(" cli.agc_rewards,");
                query.Append(" cli.correspondence_by_email,");
                query.Append(" cli.correspondence_by_post,");
                query.Append(" cli.date_details_confirmed,");
                query.Append(" cli.bank_account_name,");

                // District id or Company name
                query.Append(" cli.district_id,");
                query.Append(" cli.trading_name,");

                // Bill type/unit id
                query.Append(" cli.seq_bill_type_id,");
                query.Append("cli.rest_assn_num,");

                // Treatment type id
                query.Append(" cli.treat_type_id");
                query.Append(" FROM dbo.nc_client             cli");
                query.Append(" JOIN dbo.crm_party             pty ON cli.seq_party_id = pty.seq_party_id");
                query.Append("  JOIN dbo.crm_element_hierarchy eh  ON cli.seq_party_id = eh.element_id");
                query.Append(" LEFT JOIN");
                query.Append("	 dbo.crm_party             stf ON cli.seq_staff_id = stf.seq_party_id");
                query.Append(" LEFT JOIN");
                query.Append("	 dbo.nc_industry           ind ON cli.seq_industry_id = ind.seq_industry_id");
                query.Append(" WHERE cli.seq_party_id = " + customerNo + "");
                DataSet ds = database.ExecuteDataSet(System.Data.CommandType.Text, query.ToString());
                if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    custDetails.SeqPartyId = Convert.ToString(ds.Tables[0].Rows[0]["seq_party_id"]).Trim();
                    custDetails.SeqPartyTypeId = Convert.ToString(ds.Tables[0].Rows[0]["seq_element_type_id"]).Trim();
                    custDetails.CustomerNo = Convert.ToString(ds.Tables[0].Rows[0]["party_code"]);
                    custDetails.CustomerName = Convert.ToString(ds.Tables[0].Rows[0]["party_name"]);
                    custDetails.CustomerFName = Convert.ToString(ds.Tables[0].Rows[0]["first_name"]).Trim();
                    custDetails.CustomerLName = Convert.ToString(ds.Tables[0].Rows[0]["last_name"]).Trim();
                    custDetails.CustomerInitial = Convert.ToString(ds.Tables[0].Rows[0]["initials"]).Trim();
                    custDetails.Phone = Convert.ToString(ds.Tables[0].Rows[0]["phone_no"]).Trim();
                    custDetails.STDCode = Convert.ToString(ds.Tables[0].Rows[0]["std_code"]).Trim();
                    custDetails.Fax = Convert.ToString(ds.Tables[0].Rows[0]["fax_no"]).Trim();
                    custDetails.EMailAddress = Convert.ToString(ds.Tables[0].Rows[0]["email_address"]).Trim();
                    custDetails.WebAddress = Convert.ToString(ds.Tables[0].Rows[0]["web_address"]).Trim();
                    custDetails.StreetAddrNo = Convert.ToString(ds.Tables[0].Rows[0]["street_addr_no"]).Trim();
                    custDetails.StreetPostCode = Convert.ToString(ds.Tables[0].Rows[0]["street_post_code"]).Trim();
                    custDetails.PostalPostCode = Convert.ToString(ds.Tables[0].Rows[0]["postal_post_code"]).Trim();
                    custDetails.StreetAddr1 = Convert.ToString(ds.Tables[0].Rows[0]["street_addr_1"]).Trim();
                    custDetails.StreetAddr2 = Convert.ToString(ds.Tables[0].Rows[0]["street_addr_2"]).Trim();
                    custDetails.StreetAddr3 = Convert.ToString(ds.Tables[0].Rows[0]["street_addr_3"]).Trim();
                    custDetails.StreetAddr4 = Convert.ToString(ds.Tables[0].Rows[0]["street_addr_4"]).Trim();
                    custDetails.StreetAddr5 = Convert.ToString(ds.Tables[0].Rows[0]["street_addr_5"]).Trim();
                    custDetails.PostalAddr1 = Convert.ToString(ds.Tables[0].Rows[0]["postal_addr_1"]).Trim();
                    custDetails.PostalAddr2 = Convert.ToString(ds.Tables[0].Rows[0]["postal_addr_2"]).Trim();
                    custDetails.PostalAddr3 = Convert.ToString(ds.Tables[0].Rows[0]["postal_addr_3"]).Trim();
                    custDetails.PostalAddr4 = Convert.ToString(ds.Tables[0].Rows[0]["postal_addr_4"]).Trim();
                    custDetails.PostalAddr5 = Convert.ToString(ds.Tables[0].Rows[0]["postal_addr_5"]).Trim();
                    custDetails.Notes = Convert.ToString(ds.Tables[0].Rows[0]["notes"]).Trim();
                    custDetails.TradingName = Convert.ToString(ds.Tables[0].Rows[0]["trading_name"]).Trim();
                    custDetails.RestaurantAssnNo = Convert.ToString(ds.Tables[0].Rows[0]["rest_assn_num"]).Trim();
                    custDetails.PromptPayDisc = Convert.ToString(ds.Tables[0].Rows[0]["prompt_payment_discount"]).Trim();
                    if (Convert.ToString(ds.Tables[0].Rows[0]["active"]) == "Y")
                    {
                        custDetails.IsActive = true;
                    }
                    else
                    {
                        custDetails.IsActive = false;
                    }


                    custDetails.SeqPayMethodId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_pay_method_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_pay_method_id"])) : 0;
                    custDetails.SeqBillCycleId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_cycle_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_cycle_id"])) : 0;
                    custDetails.SeqCreditCheckId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_int_crd_chk_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_int_crd_chk_id"])) : 0;
                    custDetails.SeqBillCycle = new BillingCycle
                    {
                        BillingCycleId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_cycle_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_cycle_id"])) : 0
                    };

                    custDetails.AccMgr = new Party
                    {
                        SeqPartyId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_staff_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_staff_id"])) : 0
                    };

                    custDetails.Type = new TreatmentType
                   {
                       TreatmentTypeId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["treat_type_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["treat_type_id"])) : 0
                   };

                    custDetails.PmtMethod = new PayMethod
                    {
                        PayMethodId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_pay_method_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_pay_method_id"])) : 0
                    };

                    custDetails.CreditCtrlStatus = new CreditControlStatus
                    {
                        CreditControlStatusId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_credit_status_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_credit_status_id"])) : 0
                    };

                    custDetails.CreditCardType = new CardType
                    {
                        CardTypeCode = Convert.ToString(ds.Tables[0].Rows[0]["credit_card_type_code"])

                    };

                    custDetails.InvDelivery = new InvoiceDelivery
                    {
                        InvoiceDeliveryId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_inv_del_mode_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_inv_del_mode_id"])) : 0

                    };

                    custDetails.InvStyle = new InvoiceStyle
                    {
                        InvoiceStyleId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_inv_style_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_inv_style_id"])) : 0

                    };

                    custDetails.CustType = new CustomerType
                    {
                        CustomerTypeId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_element_type_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_element_type_id"])) : 0

                    };

                    custDetails.CustCompany = new Company
                    {
                        CompanyId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["district_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["district_id"])) : 0

                    };


                    custDetails.Score = new CreditCheckScore
                    {
                        CreditCheckScoreId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_int_crd_chk_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_int_crd_chk_id"])) : 0
                    };

                    custDetails.IndustryDetails = new Industry
                    {
                        IndustryId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_industry_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_industry_id"])) : 0,
                        IndustryCode = Convert.ToString(ds.Tables[0].Rows[0]["industry_code"]),
                        IndustryDesc = Convert.ToString(ds.Tables[0].Rows[0]["industry_desc"])
                    };

                    custDetails.SeqPriority = new Priority
                    {
                        PriorityId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_client_priority_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_client_priority_id"])) : 0
                    };

                    if (!string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["agc_rewards"])))
                    {
                        custDetails.AgcRewards = Convert.ToDateTime(Convert.ToString(ds.Tables[0].Rows[0]["agc_rewards"]));
                    }

                    if (!string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["date_details_confirmed"])))
                    {
                        custDetails.DateDetailsConfirmed = Convert.ToDateTime(Convert.ToString(ds.Tables[0].Rows[0]["date_details_confirmed"]));
                    }

                    if (!string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["alert_expiry_date"])))
                    {
                        custDetails.AlertExpiryDate = Convert.ToDateTime(Convert.ToString(ds.Tables[0].Rows[0]["alert_expiry_date"]));
                    }

                    custDetails.SeqTaxIndId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_tax_ind_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_tax_ind_id"])) : 0;
                    custDetails.BondAmt = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["bond"])) ? double.Parse(Convert.ToString(ds.Tables[0].Rows[0]["bond"])) : 0;

                    custDetails.Password = Convert.ToString(ds.Tables[0].Rows[0]["password"]).Trim();
                    custDetails.Employer = Convert.ToString(ds.Tables[0].Rows[0]["employer"]).Trim();
                    custDetails.Alert = Convert.ToString(ds.Tables[0].Rows[0]["alert"]).Trim();
                    custDetails.EstimateDate = Convert.ToString(ds.Tables[0].Rows[0]["estimate_date"]).Trim();
                    custDetails.CreditLimit = Convert.ToString(ds.Tables[0].Rows[0]["credit_limit"]).Trim();
                    custDetails.Bank = Convert.ToString(ds.Tables[0].Rows[0]["bank"]).Trim();
                    custDetails.BankBranch = Convert.ToString(ds.Tables[0].Rows[0]["bank_branch"]).Trim();
                    custDetails.BankAccNo = Convert.ToString(ds.Tables[0].Rows[0]["bank_account_no"]).Trim();
                    custDetails.CreditCardTypeCode = Convert.ToString(ds.Tables[0].Rows[0]["credit_card_type_code"]).Trim();
                    custDetails.CreditCardName = Convert.ToString(ds.Tables[0].Rows[0]["credit_card_name"]).Trim();
                    custDetails.CreditCardNo = Convert.ToString(ds.Tables[0].Rows[0]["credit_card_no"]).Trim();
                    custDetails.CreditCardExpiry = Convert.ToString(ds.Tables[0].Rows[0]["credit_card_expiry"]).Trim();
                    custDetails.CreditCardVerifyNo = Convert.ToString(ds.Tables[0].Rows[0]["credit_card_verif_no"]).Trim();
                    custDetails.CreditCardNo = Convert.ToString(ds.Tables[0].Rows[0]["credit_card_no"]).Trim();
                    custDetails.BillNotes = Convert.ToString(ds.Tables[0].Rows[0]["bill_notes"]).Trim();
                    custDetails.AvgMonthlySpend = Convert.ToString(ds.Tables[0].Rows[0]["avg_monthly_spend"]).Trim();
                    if (Convert.ToString(ds.Tables[0].Rows[0]["override_name"]) == "Y")
                    {
                        custDetails.IsNameOverride = true;
                    }
                    else
                    {
                        custDetails.IsNameOverride = false;
                    }

                    if (Convert.ToString(ds.Tables[0].Rows[0]["developer"]) == "Y")
                    {
                        custDetails.IsDeveloper = true;
                    }
                    else
                    {
                        custDetails.IsDeveloper = false;
                    }

                    if (Convert.ToString(ds.Tables[0].Rows[0]["alert_expires"]) == "Y")
                    {
                        custDetails.IsAlertExpires = true;
                    }
                    else
                    {
                        custDetails.IsAlertExpires = false;
                    }

                    if (Convert.ToString(ds.Tables[0].Rows[0]["correspondence_by_email"]) == "Y")
                    {
                        custDetails.IsCorrespondenceByEMail = true;
                    }
                    else
                    {
                        custDetails.IsCorrespondenceByEMail = false;
                    }

                    if (Convert.ToString(ds.Tables[0].Rows[0]["correspondence_by_post"]) == "Y")
                    {
                        custDetails.IsCorrespondenceByPost = true;
                    }
                    else
                    {
                        custDetails.IsCorrespondenceByPost = false;
                    }

                    custDetails.BankAccName = Convert.ToString(ds.Tables[0].Rows[0]["bank_account_name"]).Trim();
                    custDetails.SeqBillTypeId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_type_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_type_id"])) : 0;

                    custDetails.TreatmentTypeId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["treat_type_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["treat_type_id"])) : 0;
                    custDetails.SeqTaxIndicator = new TaxIndicator
                    {
                        TaxIndicatorId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_tax_ind_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_tax_ind_id"])) : 0

                    };

                    custDetails.SeqBillingUnit = new BillingUnit
                    {
                        BillingUnitId = !string.IsNullOrEmpty(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_type_id"])) ? int.Parse(Convert.ToString(ds.Tables[0].Rows[0]["seq_bill_type_id"])) : 0
                    };
                    //

                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            return custDetails;

        }
Beispiel #2
0
        public bool SaveCustomerDetails(CustomerDetails customerDetails)
        {
            bool retVal = false;
            try
            {
                StringBuilder query = new StringBuilder();
                query.Append("UPDATE crm_party set");

                if (!string.IsNullOrEmpty(customerDetails.CustomerFName))
                {
                    query.Append(" first_name = '" + customerDetails.CustomerFName.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.CustomerLName))
                {
                    query.Append(" last_name = '" + customerDetails.CustomerLName.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.CustomerInitial))
                {
                    query.Append(" initials = '" + customerDetails.CustomerInitial.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.Phone))
                {
                    query.Append(" phone_no = '" + customerDetails.Phone.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.Fax))
                {
                    query.Append(" fax_no = '" + customerDetails.Fax.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.EMailAddress))
                {
                    query.Append(" email_address = '" + customerDetails.EMailAddress.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.WebAddress))
                {
                    query.Append(" web_address = '" + customerDetails.WebAddress.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.StreetAddrNo))
                {
                    query.Append("street_addr_no = '" + customerDetails.StreetAddrNo.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.PostalPostCode))
                {
                    query.Append(" postal_post_code = '" + customerDetails.PostalPostCode.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.StreetAddr1))
                {
                    query.Append("street_addr_1 = '" + customerDetails.StreetAddr1.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.StreetAddr2))
                {
                    query.Append(" street_addr_2 = '" + customerDetails.StreetAddr2.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.StreetAddr3))
                {
                    query.Append(" street_addr_3 = '" + customerDetails.StreetAddr3.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.PostalAddr1))
                {
                    query.Append(" postal_addr_1 = '" + customerDetails.PostalAddr1.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.PostalAddr2))
                {
                    query.Append(" postal_addr_2 = '" + customerDetails.PostalAddr2.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.PostalAddr3))
                {
                    query.Append(" postal_addr_3 = '" + customerDetails.PostalAddr3.Replace("'", "''").Trim() + "',");
                }

                query.Append(" notes = '" + customerDetails.Notes + "', update_datetime =  '" + DateTime.UtcNow + "',");

                if (customerDetails.STDCode != null)
                {
                    query.Append(" std_code =  '" + customerDetails.STDCode.Replace("'", "''").Trim() + "',");
                }

                if (customerDetails.TradingName != null)
                {
                    query.Append(" trading_name =  '" + customerDetails.TradingName.Replace("'", "''").Trim() + "',");
                }


                if (customerDetails.CustomerName != null)
                {
                    query.Append(" party_name =  '" + customerDetails.CustomerName.Replace("'", "''").Trim() + "',");
                }
                query.Append(" update_user = '******', update_process = 'CMS2' WHERE seq_party_id = " + customerDetails.SeqPartyId + " ");
                int rowsAffected = database.ExecuteNonQuery(CommandType.Text, query.ToString());


                //CLIENT TABLE
                // Finance details query
                query = new StringBuilder();
                query.Append("UPDATE nc_client SET update_user = '******', update_process = '" + customerDetails.UpdateProcess + "',");
                if (customerDetails.PmtMethod != null && customerDetails.PmtMethod.PayMethodId != 0)
                {
                    query.Append(" seq_pay_method_id = " + customerDetails.PmtMethod.PayMethodId + ",");
                }

                if (customerDetails.IndustryDetails != null && customerDetails.IndustryDetails.IndustryId != 0)
                {
                    query.Append(" seq_industry_id = " + customerDetails.IndustryDetails.IndustryId + ",");
                }

                if (customerDetails.AvgMonthlySpend != null)
                {
                    query.Append(" avg_monthly_spend =  '" + customerDetails.AvgMonthlySpend.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.PromptPayDisc))
                {
                    query.Append(" prompt_payment_discount =  '" + customerDetails.PromptPayDisc.Replace("'", "''").Trim() + "',");
                }

                query.Append(" bond =  '" + customerDetails.BondAmt + "',");

                if (customerDetails.TradingName != null)
                {
                    query.Append(" trading_name =  '" + customerDetails.TradingName.Replace("'", "''").Trim() + "',");
                }

                if (customerDetails.Employer != null)
                {
                    query.Append(" employer =  '" + customerDetails.Employer.Replace("'", "''").Trim() + "',");
                }


                if (customerDetails.SeqBillingUnit != null && customerDetails.SeqBillingUnit.BillingUnitId != 0)
                {
                    query.Append("seq_bill_type_id =  " + customerDetails.SeqBillingUnit.BillingUnitId + ",");
                }

                if (customerDetails.SeqBillCycle != null && customerDetails.SeqBillCycle.BillingCycleId != 0)
                {
                    query.Append("seq_bill_cycle_id =  " + customerDetails.SeqBillCycle.BillingCycleId + ",");
                }

                if (customerDetails.Score != null && customerDetails.Score.CreditCheckScoreId != 0)
                {
                    query.Append(" seq_int_crd_chk_id =  " + customerDetails.Score.CreditCheckScoreId + ",");
                }

                if (customerDetails.InvDelivery != null && customerDetails.InvDelivery.InvoiceDeliveryId != 0)
                {
                    query.Append("seq_inv_del_mode_id = " + customerDetails.InvDelivery.InvoiceDeliveryId + ",");
                }

                if (customerDetails.InvStyle != null && customerDetails.InvStyle.InvoiceStyleId != 0)
                {
                    query.Append(" seq_inv_style_id =  " + customerDetails.InvStyle.InvoiceStyleId + ",");
                }

                if (customerDetails.SeqPriority != null && customerDetails.SeqPriority.PriorityId != 0)
                {
                    query.Append(" seq_client_priority_id =  " + customerDetails.SeqPriority.PriorityId + ",");
                }

                if (customerDetails.SeqTaxIndicator != null && customerDetails.SeqTaxIndicator.TaxIndicatorId != 0)
                {
                    query.Append(" seq_tax_ind_id =  " + customerDetails.SeqTaxIndicator.TaxIndicatorId + ",");
                }

                if (customerDetails.AlertExpiryDate != null && customerDetails.AlertExpiryDate.HasValue)
                {
                    query.Append(" alert_expiry_date =  '" + customerDetails.AlertExpiryDate.Value + "',");
                }

                if (customerDetails.AgcRewards != null && customerDetails.AgcRewards.HasValue)
                {
                    query.Append(" agc_rewards =  '" + customerDetails.AgcRewards.Value + "',");
                }

                if (customerDetails.IsAlertExpires)
                {
                    query.Append(" alert_expires = 'Y',");
                }
                else
                {
                    query.Append(" alert_expires = 'N',");
                }

                if (customerDetails.IsDeveloper)
                {
                    query.Append(" developer = 'Y',");
                }
                else
                {
                    query.Append(" developer = 'N',");
                }

                if (customerDetails.IsCorrespondenceByEMail)
                {
                    query.Append(" correspondence_by_email = 'Y',");
                }
                else
                {
                    query.Append(" correspondence_by_email = 'N',");
                }

                if (customerDetails.IsCorrespondenceByPost)
                {
                    query.Append(" correspondence_by_post = 'Y',");
                }
                else
                {
                    query.Append(" correspondence_by_post = 'N',");
                }

                if (customerDetails.DateDetailsConfirmed != null && customerDetails.DateDetailsConfirmed.HasValue)
                {
                    query.Append("date_details_confirmed =  '" + customerDetails.DateDetailsConfirmed.Value + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.RestaurantAssnNo))
                {
                    query.Append(" rest_assn_num =  '" + customerDetails.RestaurantAssnNo.Replace("'", "''").Trim() + "',");
                }

                if (customerDetails.AccMgr != null && customerDetails.AccMgr.SeqPartyId != 0)
                {
                    query.Append(" seq_staff_id =  " + customerDetails.AccMgr.SeqPartyId + ",");
                }

                if (!string.IsNullOrEmpty(customerDetails.Password))
                {
                    query.Append("password = '******'", "''").Trim() + "',");
                }


                if (!string.IsNullOrEmpty(customerDetails.Alert))
                {
                    query.Append(" alert = '" + customerDetails.Alert.Replace("'", "''").Trim() + "',");
                }


                if (!string.IsNullOrEmpty(customerDetails.CreditLimit))
                {
                    query.Append(" credit_limit =  " + customerDetails.CreditLimit.Replace("'", "''").Trim() + ",");
                }


                if (!string.IsNullOrEmpty(customerDetails.Bank))
                {
                    query.Append(" bank = '" + customerDetails.Bank.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.BankBranch))
                {
                    query.Append(" bank_branch = '" + customerDetails.BankBranch.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.BankAccNo))
                {
                    query.Append(" bank_account_no = '" + customerDetails.BankAccNo.Replace("'", "''").Trim() + "',");
                }

                if (customerDetails.CreditCardType != null && customerDetails.CreditCardType.CardTypeCode != string.Empty)
                {
                    query.Append(" credit_card_type_code = '" + customerDetails.CreditCardType.CardTypeCode.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.CreditCardName))
                {
                    query.Append(" credit_card_name = '" + customerDetails.CreditCardName.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.CreditCardNo))
                {
                    query.Append(" credit_card_no = '" + customerDetails.CreditCardNo.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.CreditCardExpiry))
                {
                    query.Append(" credit_card_expiry = '" + customerDetails.CreditCardExpiry.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.CreditCardVerifyNo))
                {
                    query.Append(" credit_card_verif_no = '" + customerDetails.CreditCardVerifyNo.Replace("'", "''").Trim() + "',");
                }

                if (!string.IsNullOrEmpty(customerDetails.BillNotes))
                {
                    query.Append(" bill_notes = '" + customerDetails.BillNotes.Replace("'", "''").Trim() + "',");
                }

                if (customerDetails.CreditCtrlStatus != null && customerDetails.CreditCtrlStatus.CreditControlStatusId != 0)
                {
                    query.Append(" seq_credit_status_id =  " + customerDetails.CreditCtrlStatus.CreditControlStatusId + ",");
                }

                if (!string.IsNullOrEmpty(customerDetails.BankAccName))
                {
                    query.Append(" bank_account_name = '" + customerDetails.BankAccName.Replace("'", "''").Trim() + "',");
                }

                query.Append(" treat_type_id =  " + customerDetails.Type.TreatmentTypeId + ",  update_datetime = '" + DateTime.UtcNow + "'  WHERE seq_party_id = " + customerDetails.SeqPartyId + " ");
                rowsAffected = database.ExecuteNonQuery(CommandType.Text, query.ToString());

                query = new StringBuilder();
                query.Append("  UPDATE crm_element_hierarchy SET update_datetime = '" + DateTime.UtcNow + "', update_user = '******', update_process = '" + customerDetails.UpdateProcess + "',");
                if (customerDetails.Type != null && customerDetails.CustType.CustomerTypeId != 0)
                {
                    query.Append(" seq_element_type_id =  '" + customerDetails.CustType.CustomerTypeId + "'");
                }

                query.Append("WHERE element_id = " + customerDetails.SeqPartyId + " AND element_struct_code = 'CLIENT' AND parent_id = 3 AND parent_element_struct_code = 'COMPANY'");
                rowsAffected = database.ExecuteNonQuery(CommandType.Text, query.ToString());
                if (rowsAffected > 0)
                {
                    retVal = true;
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            return retVal;
        }
 public bool SaveCustomerDetails(CustomerDetails customerDetails)
 {
     return Database.SaveCustomerDetails(customerDetails);
 }
Beispiel #4
0
 public bool SaveCustomerDetails(CustomerDetails customerDetails)
 {
     throw new NotImplementedException();
 }
 public bool SaveCustomerDetails(CustomerDetails customerDetails)
 {
     bool retVal = false;
     try
     {
         retVal = _dbManager.SaveCustomerDetails(customerDetails);
     }
     catch (Exception ex)
     {
         ExceptionPolicy.HandleException(ex, "Policy");
         FaultDetail faultDetail = new FaultDetail
         {
             Type = ex.Message,
             ErrorCode = 63873928
         };     //+ throw     
         throw new FaultException<FaultDetail>(faultDetail, ex.Message);
     }
     return retVal;
 }
        public CustomerDetails GetCustomerDetails(int customerNo)
        {
            CustomerDetails custDetails = new CustomerDetails();
            try
            {
                custDetails = _dbManager.GetCustomerDetails(customerNo);
            }
            catch (Exception exceptionToHandle)
            {
                ExceptionPolicy.HandleException(exceptionToHandle, "Policy");
                FaultDetail faultDetail = new FaultDetail
                {
                    Type = exceptionToHandle.Message,
                    ErrorCode = 63873928
                };     //+ throw     
                throw new FaultException<FaultDetail>(faultDetail, exceptionToHandle.Message);
            }

            return custDetails;
        }