Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
    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);
    }