private ClientMasterInfo GetRecordForSql(string sql) { LocalLayer.LocalDefine localDefine = new DAL.SqlDAL.LocalLayer.LocalDefine(); string sqlString = string.Empty; DataAccessLayer dal = new DataAccessLayer(); ClientMasterInfo clientMaster = null; SqlDataReader dr = null; try { dr = dal.GetDataReader(sql); if (dr != null) { if (dr.Read()) { clientMaster = GetRecord(dr); } } } catch (Exception Ex) { throw Ex; } finally { if (dr != null) { dr.Close(); } } return(clientMaster); }
public ClientMasterInfo GetRecord_Next(int currentRecordID) { LocalLayer.LocalDefine localDefine = new DAL.SqlDAL.LocalLayer.LocalDefine(); string sqlString = string.Empty; DataBaseCommandKeyInfo dataBaseCommandKeyInfo = new DataBaseCommandKeyInfo(); List <DataBaseCommandKeyInfo> keyList = new List <DataBaseCommandKeyInfo>(); dataBaseCommandKeyInfo.Key = "clm_iRecID"; dataBaseCommandKeyInfo.KeyValue = currentRecordID.ToString(); dataBaseCommandKeyInfo.KeyValueType = TypeCode.Int32; keyList.Add(dataBaseCommandKeyInfo); sqlString = localDefine.GetCommandSQL_Next(keyList, "ClientMaster_clm"); ClientMasterInfo clientMaster = null; try { clientMaster = GetRecordForSql(sqlString); } catch (Exception Ex) { throw Ex; } return(clientMaster); }
public ClientMasterInfo Save(ClientMasterInfo clientMasterInfo) { db.Open(); transaction = db.BeginTransaction(); try { if (this.IsExisted(clientMasterInfo.ClientID)) { clientMasterInfo = this.Update(clientMasterInfo); } else { clientMasterInfo = this.Insert(clientMasterInfo); } transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { transaction.Dispose(); transaction = null; db.Close(); } return(clientMasterInfo); }
public ReturnValueInfo UpdateRecord(ClientMasterInfo clientInfo) { if (clientInfo == null) { return(null); } ReturnValueInfo returnValue = new ReturnValueInfo(); bool isSuccess = false; try { isSuccess = this._clientMasterDA.UpdateRecord(clientInfo); } catch (Exception Ex) { throw Ex; } if (isSuccess) { returnValue.boolValue = true; returnValue.messageText = DefineConstantValue.SystemMessageText.strMessageText_I_UpdateSuccess; } else { returnValue.boolValue = false; returnValue.messageText = DefineConstantValue.SystemMessageText.strMessageText_I_UpdateFail; } return(returnValue); }
public ReturnValueInfo InsertRecord(ClientMasterInfo clientInfo) { if (clientInfo == null) { return(null); } ReturnValueInfo returnValue = new ReturnValueInfo(); ValidateValue(clientInfo, returnValue); if (!returnValue.boolValue) { return(returnValue); } bool isExistRecord = false; try { isExistRecord = this._clientMasterDA.IsExistRecord(clientInfo.ClmCClientNum); } catch (Exception Ex) { throw Ex; } if (isExistRecord) { returnValue.boolValue = false; returnValue.messageText = DefineConstantValue.SystemMessageText.strMessageText_I_RecordIsExist; return(returnValue); } bool isSuccess = false; try { isSuccess = this._clientMasterDA.InsertRecord(clientInfo); } catch (Exception Ex) { throw Ex; } if (isSuccess) { returnValue.boolValue = true; returnValue.messageText = DefineConstantValue.SystemMessageText.strMessageText_I_AddSuccess; } else { returnValue.boolValue = false; returnValue.messageText = DefineConstantValue.SystemMessageText.strMessageText_I_AddFail; } return(returnValue); }
public bool InsertRecord(ClientMasterInfo infoObject) { string l_strSQL = string.Empty; bool isSuccess = false; if (infoObject == null) { return(isSuccess); } l_strSQL = "INSERT ClientMaster_clm("; l_strSQL += "clm_cClientNum," + Environment.NewLine; l_strSQL += "clm_cEnglishName," + Environment.NewLine; l_strSQL += "clm_cChinaName," + Environment.NewLine; l_strSQL += "clm_cTaxNumber," + Environment.NewLine; l_strSQL += "clm_cLinkman," + Environment.NewLine; l_strSQL += "clm_cAddress," + Environment.NewLine; l_strSQL += "clm_cPhone," + Environment.NewLine; l_strSQL += "clm_cFax," + Environment.NewLine; l_strSQL += "clm_cWebSite," + Environment.NewLine; l_strSQL += "clm_cRemark," + Environment.NewLine; l_strSQL += "clm_cAdd," + Environment.NewLine; l_strSQL += "clm_dAddDate," + Environment.NewLine; l_strSQL += "clm_cLast," + Environment.NewLine; l_strSQL += "clm_dLastDate )" + Environment.NewLine; l_strSQL += " VALUES("; l_strSQL += "'" + infoObject.ClmCClientNum.Trim().Replace("'", "''") + "'"; l_strSQL += ",'" + infoObject.ClmCEnglishName.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCChinaName.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCTaxNumber.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCLinkman.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCAddress.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCPhone.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCFax.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCWebSite.Replace("'", "''").Trim() + "'"; l_strSQL += ",N'" + infoObject.ClmCRemark.Replace("'", "''").Trim() + "'"; l_strSQL += ",'" + infoObject.ClmCAdd.Replace("'", "''").Trim() + "'"; l_strSQL += ",GETDATE()"; l_strSQL += ",'" + infoObject.ClmCLast.Replace("'", "''") + "'"; l_strSQL += ",GETDATE())"; DataAccessLayer dal = new DataAccessLayer(); try { isSuccess = dal.ExecNonQuery(l_strSQL); } catch (Exception Ex) { throw Ex; } return(isSuccess); }
private void ValidateValue(ClientMasterInfo clientInfo, ReturnValueInfo returnValue) { string messageText = string.Empty; returnValue.boolValue = true; if (clientInfo.ClmCClientNum.Trim() == string.Empty) { returnValue.boolValue = false; returnValue.messageText = "\"客户编号\"" + DefineConstantValue.SystemMessageText.strMessageText_W_CannotEmpty; } }
public ClientMasterInfo DisplayRecord(IModelObject KeyObject) { string sqlString = string.Empty; sqlString = "SELECT clm_iRecID," + Environment.NewLine; sqlString += "clm_cClientNum," + Environment.NewLine; sqlString += "clm_cEnglishName," + Environment.NewLine; sqlString += "clm_cChinaName," + Environment.NewLine; sqlString += "clm_cTaxNumber," + Environment.NewLine; sqlString += "clm_cLinkman," + Environment.NewLine; sqlString += "clm_cAddress," + Environment.NewLine; sqlString += "clm_cPhone," + Environment.NewLine; sqlString += "clm_cFax," + Environment.NewLine; sqlString += "clm_cWebSite," + Environment.NewLine; sqlString += "clm_cRemark," + Environment.NewLine; sqlString += "clm_cAdd," + Environment.NewLine; sqlString += "clm_dAddDate," + Environment.NewLine; sqlString += "clm_cLast," + Environment.NewLine; sqlString += "clm_dLastDate " + Environment.NewLine; sqlString += " FROM ClientMaster_clm " + Environment.NewLine; sqlString += " WHERE clm_iRecID=" + KeyObject.RecordID.ToString(); DataAccessLayer dal = new DataAccessLayer(); ClientMasterInfo clientMaster = null; SqlDataReader dr = null; try { dr = dal.GetDataReader(sqlString); if (dr != null) { if (dr.Read()) { clientMaster = GetRecord(dr); } } } catch (Exception Ex) { throw Ex; } finally { if (dr != null) { dr.Close(); } } return(clientMaster); }
public ClientMasterInfo GetTableFieldLenght() { ClientMasterInfo info = null; try { info = this._clientMasterDA.GetTableFieldLenght(); } catch (Exception Ex) { throw Ex; } return(info); }
public ClientMasterInfo GetRecord(string clientNum) { ClientMasterInfo info = null; try { info = this._clientMasterDA.GetRecord(clientNum); } catch (Exception Ex) { throw Ex; } return(info); }
public ClientMasterInfo GetRecord(IModelObject KeyObject) { ClientMasterInfo info = null; try { info = this._clientMasterDA.DisplayRecord(KeyObject); } catch (Exception Ex) { throw Ex; } return(info); }
public ClientMasterInfo GetRecord_First() { ClientMasterInfo clientMasterInfo = null; try { clientMasterInfo = this._clientMasterDA.GetRecord_First(); } catch (Exception Ex) { throw Ex; } return(clientMasterInfo); }
public ClientMasterInfo GetRecord_Next(int currentRecordID) { ClientMasterInfo clientMasterInfo = null; try { clientMasterInfo = this._clientMasterDA.GetRecord_Next(currentRecordID); } catch (Exception Ex) { throw Ex; } return(clientMasterInfo); }
public ClientMasterInfo GetTableFieldLenght() { ClientMasterInfo cmInfo = new ClientMasterInfo(); cmInfo.ClmCClientNum_Lenght = 30; cmInfo.ClmCChinaName_Lenght = 50; cmInfo.ClmCEnglishName_Lenght = 100; cmInfo.ClmCTaxNumber_Lenght = 50; cmInfo.ClmCLinkman_Lenght = 50; cmInfo.ClmCAddress_Lenght = 100; cmInfo.ClmCPhone_Lenght = 50; cmInfo.ClmCFax_Lenght = 50; cmInfo.ClmCWebSite_Lenght = 50; cmInfo.ClmCRemark_Lenght = 200; return(cmInfo); }
public ClientMasterInfo GetRecord_First() { LocalLayer.LocalDefine localDefine = new DAL.SqlDAL.LocalLayer.LocalDefine(); string sqlString = string.Empty; sqlString = localDefine.GetCommandSQL_First("ClientMaster_clm"); ClientMasterInfo clientMaster = null; try { clientMaster = GetRecordForSql(sqlString); } catch (Exception Ex) { throw Ex; } return(clientMaster); }
public ClientMasterInfo[] SearchRecords(ClientMasterInfo clientMasterInfo) { ClientMasterInfo[] infos = null; List <ClientMasterInfo> deptMasterInfoList = null; try { deptMasterInfoList = this._clientMasterDA.SearchRecords(clientMasterInfo); } catch (Exception Ex) { throw Ex; } if (deptMasterInfoList != null) { infos = deptMasterInfoList.ToArray(); } return(infos); }
public bool UpdateRecord(ClientMasterInfo infoObject) { string l_strSQL = string.Empty; bool isSuccess = false; if (infoObject == null) { return(isSuccess); } l_strSQL = "UPDATE ClientMaster_clm SET "; l_strSQL += "clm_cEnglishName='" + infoObject.ClmCEnglishName.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cChinaName=N'" + infoObject.ClmCChinaName.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cTaxNumber=N'" + infoObject.ClmCTaxNumber.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cLinkman=N'" + infoObject.ClmCLinkman.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cAddress=N'" + infoObject.ClmCAddress.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cPhone=N'" + infoObject.ClmCPhone.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cFax=N'" + infoObject.ClmCFax.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cWebSite=N'" + infoObject.ClmCWebSite.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cRemark=N'" + infoObject.ClmCRemark.Replace("'", "''").Trim() + "'," + Environment.NewLine; l_strSQL += "clm_cLast='" + infoObject.ClmCLast.Replace("'", "''") + "'," + Environment.NewLine; l_strSQL += "clm_dLastDate=GETDATE() " + Environment.NewLine; l_strSQL += " WHERE clm_iRecID=" + infoObject.ClmIRecID.ToString(); DataAccessLayer dal = new DataAccessLayer(); try { isSuccess = dal.ExecNonQuery(l_strSQL); } catch (Exception Ex) { throw Ex; } return(isSuccess); }
public ClientMasterInfo Update(ClientMasterInfo clientMasterInfo) { string query = "UPDATE [dbo].[ClientMaster] " + "SET " + " [CompanyName] = @CompanyName " + ", [CompanyType] = @CompanyType " + ", [RegPlace] = @RegPlace " + ", [RegNo] = @RegNo " + ", [TaxCodeNo] = @TaxCodeNo " + ", [OrganizationCode] = @OrganizationCode " + ", [SocialUnifiedCreditCode] = @SocialUnifiedCreditCode " + ", [ExternalDebtNo] = @ExternalDebtNo " + ", [RegCapitalCurrency] = @RegCapitalCurrency " + ", [RegCapital] = @RegCapital " + ", [RegShareCurrency] = @RegShareCurrency " + ", [RegShare] = @RegShare " + ", [NotRegCapitalCurrency] = @NotRegCapitalCurrency " + ", [NotRegCapital] = @NotRegCapital " + ", [TotalCreditor] = @TotalCreditor " + ", [Website] = @Website " + ", [Director] = @Director " + ", [DirectorIdenNo] = @DirectorIdenNo " + ", [DirectorPhone] = @DirectorPhone " + ", [DirectorAddress] = @DirectorAddress " + ", [GenManager] = @GenManager " + ", [GenManagerIdenNo] = @GenManagerIdenNo " + ", [GenManagerPhone] = @GenManagerPhone " + ", [GenManagerAddress] = @GenManagerAddress " + ", [Secretary] = @Secretary " + ", [SecretaryIdenNo] = @SecretaryIdenNo " + ", [SecretaryPhone] = @SecretaryPhone " + ", [SecretaryAddress] = @SecretaryAddress " + ", [Supervisor] = @Supervisor " + ", [SupervisorIdenNo] = @SupervisorIdenNo " + ", [SupervisorPhone] = @SupervisorPhone " + ", [SupervisorAddress] = @SupervisorAddress " + ", [Admin] = @Admin " + ", [AdminIdenNo] = @AdminIdenNo " + ", [AdminPhone] = @AdminPhone " + ", [AdminAddress] = @AdminAddress " + ", [ContactEmail] = @ContactEmail " + ", [LegalRepresentative] = @LegalRepresentative " + ", [Relationship] = @Relationship " + ", [EntrustAgent] = @EntrustAgent " + ", [CreateUser] = @CreateUser " + ", [CreateDate] = @CreateDate " + ", [LastModifiedUser] = @LastModifiedUser " + ", [LastModifiedDate] = @LastModifiedDate " + "WHERE ClientID = @ClientID "; db.Execute(query, clientMasterInfo, transaction); // Delete record List <int> clientShareholderRowNoList = new List <int>(); List <string> responsibleStaffStaffIDList = new List <string>(); List <string> currencyCodeList = new List <string>(); List <int> memberListToBeDeleted = new List <int>(); List <int> courtJudgeListToBeDeleted = new List <int>(); foreach (ClientShareholderInfo clientShareholderInfo in clientMasterInfo.ClientShareholderList) { clientShareholderRowNoList.Add(clientShareholderInfo.RowNo); } foreach (ResponsibleStaffInfo responsibleStaffInfo in clientMasterInfo.ResponsibleStaffList) { responsibleStaffStaffIDList.Add(responsibleStaffInfo.StaffID); } foreach (CurrencyInfo currencyInfo in clientMasterInfo.CurrencyList) { currencyCodeList.Add(currencyInfo.CurrencyCode); } foreach (ClientMemberInfo info in clientMasterInfo.ClientMemberList) { memberListToBeDeleted.Add(info.RowNo); } foreach (ClientCourtJudgeInfo info in clientMasterInfo.ClientCourtJudgeList) { courtJudgeListToBeDeleted.Add(info.RowNo); } this.DeleteResponsibleStaffNotInTheList(responsibleStaffStaffIDList, clientMasterInfo.ClientID); this.DeleteCurrencyNotInTheList(currencyCodeList, clientMasterInfo.ClientID); ClientShareholder cs = new ClientShareholder(this.db, transaction); cs.DeleteClientShareholderNotInTheList(clientShareholderRowNoList, clientMasterInfo.ClientID); foreach (ClientShareholderInfo clientShareholderInfo in clientMasterInfo.ClientShareholderList) { clientShareholderInfo.ClientID = clientMasterInfo.ClientID; clientShareholderInfo.CreateUser = clientMasterInfo.LastModifiedUser; clientShareholderInfo.CreateDate = DateTime.Now; clientShareholderInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser; clientShareholderInfo.LastModifiedDate = DateTime.Now; cs.Save(clientShareholderInfo); } foreach (ResponsibleStaffInfo responsibleStaffInfo in clientMasterInfo.ResponsibleStaffList) { responsibleStaffInfo.CreateUser = clientMasterInfo.LastModifiedUser; responsibleStaffInfo.CreateDate = DateTime.Now; responsibleStaffInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser; responsibleStaffInfo.LastModifiedDate = DateTime.Now; this.SaveResponsibleStaffInfo(responsibleStaffInfo, clientMasterInfo.ClientID); } foreach (CurrencyInfo currencyInfo in clientMasterInfo.CurrencyList) { currencyInfo.CreateUser = clientMasterInfo.LastModifiedUser; currencyInfo.CreateDate = DateTime.Now; currencyInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser; currencyInfo.LastModifiedDate = DateTime.Now; this.SaveCurrencyInfo(currencyInfo, clientMasterInfo.ClientID); } ClientMember cm = new ClientMember(this.db, transaction); cm.deleteClientMemberTypeNotInList(memberListToBeDeleted, clientMasterInfo.ClientID); if (clientMasterInfo.ClientMemberList != null) { foreach (ClientMemberInfo info in clientMasterInfo.ClientMemberList) { info.ClientID = clientMasterInfo.ClientID; info.CreateUser = clientMasterInfo.LastModifiedUser; info.CreateDate = DateTime.Now; info.LastModifiedUser = clientMasterInfo.LastModifiedUser; info.LastModifiedDate = DateTime.Now; cm.Save(info); } } //Court Judge ClientCourtJudge ClientCourtJudge = new ClientCourtJudge(this.db, transaction); ClientCourtJudge.DeleteClientCourtJudgeNotInTheList(courtJudgeListToBeDeleted, clientMasterInfo.ClientID); if (clientMasterInfo.ClientCourtJudgeList != null) { foreach (ClientCourtJudgeInfo info in clientMasterInfo.ClientCourtJudgeList) { info.ClientID = clientMasterInfo.ClientID; info.CreateUser = clientMasterInfo.LastModifiedUser; info.CreateDate = DateTime.Now; info.LastModifiedUser = clientMasterInfo.LastModifiedUser; info.LastModifiedDate = DateTime.Now; ClientCourtJudge.Save(info); } } return(clientMasterInfo); }
public List <ClientMasterInfo> SearchRecords(ClientMasterInfo clientMasterInfo) { string sqlString = string.Empty; string whereString = string.Empty; sqlString = "SELECT TOP 100 clm_iRecID," + Environment.NewLine; sqlString += "clm_cClientNum," + Environment.NewLine; sqlString += "clm_cEnglishName," + Environment.NewLine; sqlString += "clm_cChinaName," + Environment.NewLine; sqlString += "clm_cTaxNumber," + Environment.NewLine; sqlString += "clm_cLinkman," + Environment.NewLine; sqlString += "clm_cAddress," + Environment.NewLine; sqlString += "clm_cPhone," + Environment.NewLine; sqlString += "clm_cFax," + Environment.NewLine; sqlString += "clm_cWebSite," + Environment.NewLine; sqlString += "clm_cRemark," + Environment.NewLine; sqlString += "clm_cAdd," + Environment.NewLine; sqlString += "clm_dAddDate," + Environment.NewLine; sqlString += "clm_cLast," + Environment.NewLine; sqlString += "clm_dLastDate " + Environment.NewLine; sqlString += " FROM ClientMaster_clm "; if (clientMasterInfo != null) { whereString = " WHERE 1=1 "; if (clientMasterInfo.ClmCClientNum.Trim().Length > 0) { whereString += " AND clm_cClientNum='" + clientMasterInfo.ClmCClientNum.Trim().Replace("'", "''") + "'"; } if (clientMasterInfo.ClmCChinaName.Trim().Length > 0) { //whereString += " AND clm_cChinaName LIKE N'" + General.ReplaceSQLLikeCondition(clientMasterInfo.ClmCChinaName.Trim().Replace("'", "''")) + "'"; } } sqlString += whereString; DataAccessLayer dal = new DataAccessLayer(); List <ClientMasterInfo> clientMasterInfoList = null; SqlDataReader dr = null; try { dr = dal.GetDataReader(sqlString); if (dr != null) { clientMasterInfoList = new List <ClientMasterInfo>(); ClientMasterInfo cmInfo = null; while (dr.Read()) { cmInfo = GetRecord(dr); clientMasterInfoList.Add(cmInfo); } } } catch (Exception Ex) { throw Ex; } finally { if (dr != null) { dr.Close(); } } return(clientMasterInfoList); }
private ClientMasterInfo GetRecord(SqlDataReader dr) { ClientMasterInfo clientMaster = null; if (dr != null) { clientMaster = new ClientMasterInfo(); if (dr["clm_iRecID"] != null) { clientMaster.ClmIRecID = Convert.ToInt32(dr["clm_iRecID"]); } if (dr["clm_cClientNum"] != null) { clientMaster.ClmCClientNum = dr["clm_cClientNum"].ToString().Trim(); } if (dr["clm_cEnglishName"] != null) { clientMaster.ClmCEnglishName = dr["clm_cEnglishName"].ToString().Trim(); } if (dr["clm_cChinaName"] != null) { clientMaster.ClmCChinaName = dr["clm_cChinaName"].ToString().Trim(); } if (dr["clm_cTaxNumber"] != null) { clientMaster.ClmCTaxNumber = dr["clm_cTaxNumber"].ToString().Trim(); } if (dr["clm_cLinkman"] != null) { clientMaster.ClmCLinkman = dr["clm_cLinkman"].ToString().Trim(); } if (dr["clm_cAddress"] != null) { clientMaster.ClmCAddress = dr["clm_cAddress"].ToString().Trim(); } if (dr["clm_cPhone"] != null) { clientMaster.ClmCPhone = dr["clm_cPhone"].ToString().Trim(); } if (dr["clm_cFax"] != null) { clientMaster.ClmCFax = dr["clm_cFax"].ToString().Trim(); } if (dr["clm_cWebSite"] != null) { clientMaster.ClmCWebSite = dr["clm_cWebSite"].ToString().Trim(); } if (dr["clm_cRemark"] != null) { clientMaster.ClmCRemark = dr["clm_cRemark"].ToString().Trim(); } if (dr["clm_cAdd"] != null) { clientMaster.ClmCAdd = dr["clm_cAdd"].ToString().Trim(); } if (dr["clm_dAddDate"] != null) { clientMaster.ClmDAddDate = Convert.ToDateTime(dr["clm_dAddDate"]); } if (dr["clm_cLast"] != null) { clientMaster.ClmCLast = dr["clm_cLast"].ToString().Trim(); } if (dr["clm_dLastDate"] != null) { clientMaster.ClmDLastDate = Convert.ToDateTime(dr["clm_dLastDate"]); } } return(clientMaster); }
public ClientMasterInfo Insert(ClientMasterInfo clientMasterInfo) { string query = "INSERT INTO [dbo].[ClientMaster] " + " ( [CompanyName] " + ",[CompanyType] " + ",[RegPlace] " + ",[RegNo] " + ",[TaxCodeNo] " + ",[OrganizationCode] " + ",[SocialUnifiedCreditCode] " + ",[ExternalDebtNo] " + ",[RegCapitalCurrency] " + ",[RegCapital] " + ",[RegShareCurrency] " + ",[RegShare] " + ",[NotRegCapitalCurrency] " + ",[NotRegCapital] " + ",[TotalCreditor] " + ",[Website] " + ",[Director] " + ",[DirectorIdenNo] " + ",[DirectorPhone] " + ",[DirectorAddress] " + ",[GenManager] " + ",[GenManagerIdenNo] " + ",[GenManagerPhone] " + ",[GenManagerAddress] " + ",[Secretary] " + ",[SecretaryIdenNo] " + ",[SecretaryPhone] " + ",[SecretaryAddress] " + ",[Supervisor] " + ",[SupervisorIdenNo] " + ",[SupervisorPhone] " + ",[SupervisorAddress] " + ",[Admin] " + ",[AdminIdenNo] " + ",[AdminPhone] " + ",[AdminAddress] " + ",[ContactEmail] " + ",[LegalRepresentative] " + ",[Relationship] " + ",[EntrustAgent] " + ",[CreateUser] " + ",[CreateDate] " + ",[LastModifiedUser] " + ",[LastModifiedDate] " + ") " + "VALUES ( @CompanyName " + ",@CompanyType " + ",@RegPlace " + ",@RegNo " + ",@TaxCodeNo " + ",@OrganizationCode " + ",@SocialUnifiedCreditCode " + ",@ExternalDebtNo " + ",@RegCapitalCurrency " + ",@RegCapital " + ",@RegShareCurrency " + ",@RegShare " + ",@NotRegCapitalCurrency " + ",@NotRegCapital " + ",@TotalCreditor " + ",@Website " + ",@Director " + ",@DirectorIdenNo " + ",@DirectorPhone " + ",@DirectorAddress " + ",@GenManager " + ",@GenManagerIdenNo " + ",@GenManagerPhone " + ",@GenManagerAddress " + ",@Secretary " + ",@SecretaryIdenNo " + ",@SecretaryPhone " + ",@SecretaryAddress " + ",@Supervisor " + ",@SupervisorIdenNo " + ",@SupervisorPhone " + ",@SupervisorAddress " + ",@Admin " + ",@AdminIdenNo " + ",@AdminPhone " + ",@AdminAddress " + ",@ContactEmail " + ",@LegalRepresentative " + ",@Relationship " + ",@EntrustAgent " + ",@CreateUser " + ",@CreateDate " + ",@LastModifiedUser " + ",@LastModifiedDate " + ");select SCOPE_IDENTITY(); "; int id = ((List <int>)db.Query <int>(query, clientMasterInfo, transaction))[0]; string tmpString = string.Format("00000000{0}", id); clientMasterInfo.ClientID = "C" + tmpString.Substring(tmpString.Length - 8); if (clientMasterInfo.ClientShareholderList != null) { ClientShareholder cs = new ClientShareholder(this.db, transaction); foreach (ClientShareholderInfo clientShareholderInfo in clientMasterInfo.ClientShareholderList) { clientShareholderInfo.ClientID = clientMasterInfo.ClientID; clientShareholderInfo.CreateUser = clientMasterInfo.LastModifiedUser; clientShareholderInfo.CreateDate = DateTime.Now; clientShareholderInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser; clientShareholderInfo.LastModifiedDate = DateTime.Now; cs.Save(clientShareholderInfo); } } if (clientMasterInfo.ResponsibleStaffList != null) { foreach (ResponsibleStaffInfo responsibleStaffInfo in clientMasterInfo.ResponsibleStaffList) { responsibleStaffInfo.ClientID = clientMasterInfo.ClientID; responsibleStaffInfo.CreateUser = clientMasterInfo.LastModifiedUser; responsibleStaffInfo.CreateDate = DateTime.Now; responsibleStaffInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser; responsibleStaffInfo.LastModifiedDate = DateTime.Now; this.InsertResponsibleStaff(responsibleStaffInfo); } } if (clientMasterInfo.CurrencyList != null) { foreach (CurrencyInfo currencyInfo in clientMasterInfo.CurrencyList) { currencyInfo.ClientID = clientMasterInfo.ClientID; currencyInfo.CreateUser = clientMasterInfo.LastModifiedUser; currencyInfo.CreateDate = DateTime.Now; currencyInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser; currencyInfo.LastModifiedDate = DateTime.Now; this.InsertCurrency(currencyInfo); } } //Client Member if (clientMasterInfo.ClientMemberList != null) { ClientMember cm = new ClientMember(this.db, transaction); foreach (ClientMemberInfo info in clientMasterInfo.ClientMemberList) { info.ClientID = clientMasterInfo.ClientID; info.CreateUser = clientMasterInfo.LastModifiedUser; info.CreateDate = DateTime.Now; info.LastModifiedUser = clientMasterInfo.LastModifiedUser; info.LastModifiedDate = DateTime.Now; cm.Save(info); } } //Court Judge if (clientMasterInfo.ClientCourtJudgeList != null) { ClientCourtJudge ClientCourtJudge = new ClientCourtJudge(this.db, transaction); foreach (ClientCourtJudgeInfo info in clientMasterInfo.ClientCourtJudgeList) { info.ClientID = clientMasterInfo.ClientID; info.CreateUser = clientMasterInfo.LastModifiedUser; info.CreateDate = DateTime.Now; info.LastModifiedUser = clientMasterInfo.LastModifiedUser; info.LastModifiedDate = DateTime.Now; ClientCourtJudge.Save(info); } } return(clientMasterInfo); }