681 |
681 |
// SQL??
|
682 |
682 |
sql = new StringBuilder();
|
683 |
683 |
sql.Append("select ");
|
684 |
|
sql.Append(" ifnull(Bd.SEQNO, 1) as SEQNO ");
|
685 |
|
sql.Append(" , ifnull(Bdd.LINECOUNT, 0) as LINECOUNT ");
|
686 |
|
sql.Append(" , ifnull(Bdd.COMPANYCODE, CLD.CompanyCode) as COMPANYCODE ");
|
687 |
|
sql.Append(" , ifnull(Scm.COMPANYNAME, CLD.CompanyName) as COMPANYNAME ");
|
|
684 |
sql.Append(" ifnull(Bd.SeqNo, 1) as SeqNo ");
|
|
685 |
sql.Append(" , ifnull(Bdd.LineCount, 0) as LineCount ");
|
|
686 |
sql.Append(" , ifnull(Bdd.CompanyCode, Cld.CompanyCode) as CompanyCode ");
|
|
687 |
sql.Append(" , ifnull(Scm.CompanyName, Cld.CompanyName) as CompanyName ");
|
688 |
688 |
sql.Append(" , Sc.DisplayOrder as DisplayOrder ");
|
689 |
|
sql.Append(" , ifnull(Bdd.CONSTRUCTIONCODE, CL.ConstructionCode) as CONSTRUCTIONCODE ");
|
690 |
|
sql.Append(" , ifnull(Bdd.FIELDNAME, CBD.DetailString) as FIELDNAME ");
|
691 |
|
sql.Append(" , Bdd.BILLPRICE as BILLPRICE ");
|
692 |
|
sql.Append(" , Bdd.HIGHWPRICE as HIGHWPRICE ");
|
693 |
|
sql.Append(" , Bdd.HARDWPRICE as HARDWPRICE ");
|
694 |
|
sql.Append(" , Bdd.INDSWASTETAX as INDSWASTETAX ");
|
|
689 |
sql.Append(" , ifnull(Bdd.ConstructionCode, Cl.ConstructionCode) as ConstructionCode ");
|
|
690 |
sql.Append(" , ifnull(Bdd.FieldName, Cbd.DetailString) as FieldName ");
|
|
691 |
sql.Append(" , Bdd.BillPrice as BillPrice ");
|
|
692 |
sql.Append(" , Bdd.HighwPrice as HighwPrice ");
|
|
693 |
sql.Append(" , Bdd.HardwPrice as HardwPrice ");
|
|
694 |
sql.Append(" , Bdd.IndswasteTax as IndswasteTax ");
|
695 |
695 |
sql.Append(" , DATE_FORMAT(Bdd.UpdateDate, '%Y/%m/%d %H:%i:%s') as UpdateDate ");
|
696 |
696 |
sql.Append(" , ifnull(Bdd.Note, '') as Bikou ");
|
697 |
|
sql.Append(" , ifnull(Pdd.BILLPRICE, 0) as KojiSeikyu ");
|
|
697 |
sql.Append(" , ifnull(Pdd.BillPrice, 0) as KojiSeikyu ");
|
698 |
698 |
sql.Append(" , ifnull(Pdd.DiscountPrice, 0) as KojiNebiki ");
|
699 |
699 |
sql.Append(" , ifnull(Pdd.OffsetPrice, 0) as KojiSousai ");
|
700 |
700 |
sql.Append(" , ifnull(Pdd.NextCoPrice, 0) as JikaiKurikosi ");
|
701 |
|
sql.Append(" , ifnull(Pdd.HIGHWPRICE, 0) as KojiKousoku ");
|
702 |
|
sql.Append(" , ifnull(Pdd.HARDWPRICE, 0) as KojiKanamono ");
|
703 |
|
sql.Append(" , ifnull(Pdd.INDSWASTETAX, 0) as KojiSannhaiZei ");
|
|
701 |
sql.Append(" , ifnull(Pdd.HighwPrice, 0) as KojiKousoku ");
|
|
702 |
sql.Append(" , ifnull(Pdd.HardwPrice, 0) as KojiKanamono ");
|
|
703 |
sql.Append(" , ifnull(Pdd.IndswasteTax, 0) as KojiSannhaiZei ");
|
704 |
704 |
sql.Append(" , ifnull(Pdd.CnstrPrice, 0) as CnstrPrice ");
|
705 |
|
sql.Append(" , ifnull(Pdd.CNSTRPRICEEXIST, - 1) as CNSTRPRICEEXIST ");
|
|
705 |
sql.Append(" , ifnull(Pdd.CnstrPriceExist, - 1) as CnstrPriceExist ");
|
706 |
706 |
sql.Append(" , ifnull(Pdd.ApprovalPersonCode, 0) as ApprovalPersonCode ");
|
707 |
707 |
sql.Append(" , ifnull(Picm.SealPrintName, '') as TantoNM ");
|
708 |
708 |
sql.Append(" , DATE_FORMAT( ");
|
... | ... | |
715 |
715 |
sql.Append(" , ifnull(Cbi.ConstrSubPersonCode, 0) as ConstrSubPersonCode ");
|
716 |
716 |
sql.Append(" , ifnull(Cbi.ConstructionInstructor, 0) as ConstructionInstructor ");
|
717 |
717 |
sql.Append(" , Picm2.DepartmentCode ");
|
718 |
|
sql.Append(" , case ifnull(Cbi.PurchaseOrderMailingDate, '') ");
|
719 |
|
sql.Append(" when '' then '' ");
|
|
718 |
sql.Append(" , case ifnull(Pod.SendDate, '') ");
|
|
719 |
sql.Append(" when '' then '?~' ");
|
720 |
720 |
sql.Append(" when '2001/01/01' then '?~' ");
|
721 |
721 |
sql.Append(" else '??' ");
|
722 |
722 |
sql.Append(" end as PurchaseOrderMailingDate ");
|
723 |
|
sql.Append(" , case ifnull(Cbi.PurchaseOrderReturnDate, '') ");
|
724 |
|
sql.Append(" when '' then '' ");
|
|
723 |
sql.Append(" , case ifnull(Pod.ReturnCheckDate, '') ");
|
|
724 |
sql.Append(" when '' then '?~' ");
|
725 |
725 |
sql.Append(" when '2001/01/01' then '?~' ");
|
726 |
726 |
sql.Append(" else '??' ");
|
727 |
727 |
sql.Append(" end as PurchaseOrderReturnDate ");
|
728 |
|
sql.Append(" , case ifnull(Pa.PERSONCODE, 0) ");
|
729 |
|
sql.Append(" when 0 then case Bdd.CONSTRUCTIONCODE ");
|
|
728 |
sql.Append(" , case ifnull(Pa.PersonCode, 0) ");
|
|
729 |
sql.Append(" when 0 then case Cld.ConstructionCode ");
|
730 |
730 |
sql.Append(" when 0 then '' ");
|
731 |
731 |
sql.Append(" else '?~' ");
|
732 |
732 |
sql.Append(" end ");
|
733 |
733 |
sql.Append(" else '??' ");
|
734 |
734 |
sql.Append(" end as PaData ");
|
735 |
|
sql.Append(" , CLD.LineCount as LinePoint ");
|
736 |
|
sql.AppendFormat(" , PERIOD_DIFF({0} ,DATE_FORMAT(CL.ConstructionStart, '%Y%m')) + {1} AS ColPoint ", m_Select_TargetDate, Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1);
|
|
735 |
sql.Append(" , Cld.LineCount as LinePoint ");
|
|
736 |
sql.AppendFormat(" , PERIOD_DIFF({0} ,DATE_FORMAT(Cl.ConstructionStart, '%Y%m')) + {1} AS ColPoint ", m_Select_TargetDate, Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1);
|
737 |
737 |
sql.Append("from ");
|
738 |
|
sql.Append(" ConstructionLedgerDetail as CLD ");
|
739 |
|
sql.Append(" inner join ConstructionLedger as CL on CL.ConstructionCode = CLD.ConstructionCode ");
|
740 |
|
sql.Append(" and CL.ComplateFlg = 0 ");
|
741 |
|
sql.Append(" inner join ConstructionBaseinfoDetail as CBD on CBD.ConstructionCode = CLD.ConstructionCode ");
|
742 |
|
sql.Append(" and CBD.DetailNo = 2 ");
|
743 |
|
sql.Append(" inner join SubContractorMaster as Sc on Sc.COMPANYCODE = CLD.COMPANYCODE ");
|
|
738 |
sql.Append(" ConstructionLedgerDetail as Cld ");
|
|
739 |
sql.Append(" inner join ConstructionLedger as Cl on Cl.ConstructionCode = Cld.ConstructionCode ");
|
|
740 |
sql.Append(" and Cl.ComplateFlg = 0 ");
|
|
741 |
sql.Append(" inner join ConstructionBaseinfoDetail as Cbd on Cbd.ConstructionCode = Cld.ConstructionCode ");
|
|
742 |
sql.Append(" and Cbd.DetailNo = 2 ");
|
|
743 |
sql.Append(" inner join SubContractorMaster as Sc on Sc.COMPANYCODE = Cld.CompanyCode ");
|
744 |
744 |
sql.AppendFormat(" and Sc.LABOURKIND = {0} ", m_Labourkind);
|
745 |
|
sql.Append(" left join ConstructionLedgerExcute AS CLE on CLE.ConstructionCode = CLD.ConstructionCode ");
|
746 |
|
sql.Append(" and CLE.GroupCount = CLD.GroupCount ");
|
747 |
|
sql.Append(" and CLE.LineCount = CLD.LineCount ");
|
748 |
|
sql.AppendFormat(" and CLE.ColumnCount = (PERIOD_DIFF({0} ,DATE_FORMAT(CL.ConstructionStart, '%Y%m')) + {1}) ", m_Select_TargetDate, Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1);
|
|
745 |
sql.Append(" left join ConstructionLedgerExcute AS Cle on Cle.ConstructionCode = Cld.ConstructionCode ");
|
|
746 |
sql.Append(" and Cle.GroupCount = Cld.GroupCount ");
|
|
747 |
sql.Append(" and Cle.LineCount = Cld.LineCount ");
|
|
748 |
sql.AppendFormat(" and Cle.ColumnCount = (PERIOD_DIFF({0} ,DATE_FORMAT(CL.ConstructionStart, '%Y%m')) + {1}) ", m_Select_TargetDate, Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1);
|
749 |
749 |
sql.Append(" left join ( ");
|
750 |
750 |
sql.Append(" BillingData as Bd join ( ");
|
751 |
751 |
sql.Append(" BillingDataDetail as Bdd join SubContractorMaster as Scm ");
|
752 |
|
sql.Append(" on Bdd.COMPANYCODE = Scm.COMPANYCODE ");
|
753 |
|
sql.AppendFormat(" and Scm.LABOURKIND = {0} ", m_Labourkind);
|
|
752 |
sql.Append(" on Bdd.CompanyCode = Scm.CompanyCode ");
|
|
753 |
sql.AppendFormat(" and Scm.LabourKind = {0} ", m_Labourkind);
|
754 |
754 |
sql.Append(" left join ( ");
|
755 |
755 |
sql.Append(" PaymentDataDetail as Pdd ");
|
756 |
756 |
sql.Append(" left join PersonInChargeMaster as Picm ");
|
757 |
|
sql.Append(" on ifnull(Pdd.ApprovalPersonCode, - 1) = Picm.PERSONCODE ");
|
|
757 |
sql.Append(" on ifnull(Pdd.ApprovalPersonCode, - 1) = Picm.PersonCode ");
|
758 |
758 |
sql.Append(" ) ");
|
759 |
|
sql.Append(" on Bdd.COMPANYCODE = Pdd.COMPANYCODE ");
|
760 |
|
sql.Append(" and Bdd.TARGETDATE = Pdd.TARGETDATE ");
|
761 |
|
sql.Append(" and Bdd.SEQNO = Pdd.SEQNO ");
|
762 |
|
sql.Append(" and Bdd.LINECOUNT = Pdd.LINECOUNT ");
|
|
759 |
sql.Append(" on Bdd.CompanyCode = Pdd.CompanyCode ");
|
|
760 |
sql.Append(" and Bdd.TargetDate = Pdd.TargetDate ");
|
|
761 |
sql.Append(" and Bdd.SeqNo = Pdd.SeqNo ");
|
|
762 |
sql.Append(" and Bdd.LineCount = Pdd.LineCount ");
|
|
763 |
sql.Append(" ) ");
|
|
764 |
sql.Append(" on Bd.CompanyCode = BdD.CompanyCode ");
|
|
765 |
sql.Append(" and Bd.TargetDate = BdD.TargetDate ");
|
|
766 |
sql.Append(" and Bd.SeqNo = BdD.SeqNo ");
|
|
767 |
sql.AppendFormat(" and Bd.TargetDate = {0} ", m_Select_TargetDate);
|
|
768 |
sql.Append(" ) on Bd.COMPANYCODE = Cld.CompanyCode ");
|
|
769 |
sql.Append(" and Bdd.ConstructionCode = Cld.ConstructionCode ");
|
|
770 |
sql.Append(" left join ( ");
|
|
771 |
sql.Append(" PurchaseOrderDate as Pod ");
|
|
772 |
sql.Append(" ) on Cld.CompanyCode = Pod.CompanyCode ");
|
|
773 |
sql.Append(" and Cld.ConstructionCode = Pod.ConstructionCode ");
|
|
774 |
sql.Append(" left join ( ");
|
|
775 |
sql.Append(" ConstructionBaseInfo as Cbi ");
|
763 |
776 |
sql.Append(" left join ( ");
|
764 |
|
sql.Append(" ConstructionBaseInfo as Cbi ");
|
765 |
|
sql.Append(" left join ( ");
|
766 |
|
sql.Append(" PersonInChargeMaster as Picm2 ");
|
767 |
|
sql.Append(" left join ApprovalMaster as Am ");
|
768 |
|
sql.Append(" on Picm2.DEPARTMENTCODE = Am.DEPARTMENTCODE ");
|
769 |
|
sql.Append(" and Am.ApprovalCode = 3 ");
|
770 |
|
sql.Append(" and ApprovalAuthority = 1 ");
|
771 |
|
sql.Append(" ) ");
|
772 |
|
sql.Append(" on Cbi.ConstructionPersonCode = Picm2.PERSONCODE ");
|
773 |
|
sql.Append(" left join ProcessApproval as Pa ");
|
774 |
|
sql.Append(" on Cbi.CONSTRUCTIONCODE = Pa.CONSTRUCTIONCODE ");
|
775 |
|
sql.Append(" and Am.APPROVALPERSON = Pa.PERSONCODE ");
|
776 |
|
sql.Append(" and Pa.SEQNO > 1 ");
|
777 |
|
sql.Append(" and Pa.APPROVALSTATUS = 2 ");
|
|
777 |
sql.Append(" PersonInChargeMaster as Picm2 ");
|
|
778 |
sql.Append(" left join ApprovalMaster as Am ");
|
|
779 |
sql.Append(" on Picm2.DepartmentCode = Am.DepartmentCode ");
|
|
780 |
sql.Append(" and Am.ApprovalCode = 3 ");
|
|
781 |
sql.Append(" and ApprovalAuthority = 1 ");
|
778 |
782 |
sql.Append(" ) ");
|
779 |
|
sql.Append(" on Bdd.CONSTRUCTIONCODE = Cbi.CONSTRUCTIONCODE ");
|
|
783 |
sql.Append(" on Cbi.ConstructionPersonCode = Picm2.PersonCode ");
|
|
784 |
sql.Append(" left join ProcessApproval as Pa ");
|
|
785 |
sql.Append(" on Cbi.ConstructionCode = Pa.ConstructionCode ");
|
|
786 |
sql.Append(" and Am.ApprovalPerson = Pa.PersonCode ");
|
|
787 |
sql.Append(" and Pa.SeqNo > 1 ");
|
|
788 |
sql.Append(" and Pa.ApprovalStatus = 2 ");
|
780 |
789 |
sql.Append(" ) ");
|
781 |
|
sql.Append(" on Bd.COMPANYCODE = BdD.COMPANYCODE ");
|
782 |
|
sql.Append(" and Bd.TARGETDATE = BdD.TARGETDATE ");
|
783 |
|
sql.Append(" and Bd.SEQNO = BdD.SEQNO ");
|
784 |
|
sql.AppendFormat(" and Bd.TARGETDATE = {0} ", m_Select_TargetDate);
|
785 |
|
sql.Append(") on Bd.COMPANYCODE = CLD.CompanyCode ");
|
786 |
|
sql.Append("and Bdd.CONSTRUCTIONCODE = CLD.CONSTRUCTIONCODE ");
|
|
790 |
sql.Append(" on Cld.ConstructionCode = Cbi.ConstructionCode ");
|
|
791 |
|
787 |
792 |
sql.Append("where ");
|
788 |
|
sql.Append(" CLD.GroupCount = 2 ");
|
789 |
|
sql.Append(" and CLD.CompanyCode > 0 ");
|
790 |
|
sql.AppendFormat(" and CLD.CompanyType = {0}", m_Labourkind);
|
|
793 |
sql.Append(" Cld.GroupCount = 2 ");
|
|
794 |
sql.Append(" and Cld.CompanyCode > 0 ");
|
|
795 |
sql.AppendFormat(" and Cld.CompanyType = {0}", m_Labourkind);
|
|
796 |
|
791 |
797 |
sql.Append(" ");
|
792 |
798 |
sql.Append("union ");
|
793 |
799 |
sql.Append(" ");
|
|
800 |
|
794 |
801 |
sql.Append("select ");
|
795 |
|
sql.Append(" ifnull(Bd.SEQNO, 1) as SEQNO ");
|
796 |
|
sql.Append(" , ifnull(Bdd.LINECOUNT, 0) as LINECOUNT ");
|
797 |
|
sql.Append(" , ifnull(Bdd.COMPANYCODE, 0) as COMPANYCODE ");
|
798 |
|
sql.Append(" , ifnull(Scm.COMPANYNAME, \"\") as COMPANYNAME ");
|
|
802 |
sql.Append(" ifnull(Bd.SeqNo, 1) as SeqNo ");
|
|
803 |
sql.Append(" , ifnull(Bdd.LineCount, 0) as LineCount ");
|
|
804 |
sql.Append(" , ifnull(Bdd.CompanyCode, 0) as CompanyCode ");
|
|
805 |
sql.Append(" , ifnull(Scm.CompanyName, \"\") as CompanyName ");
|
799 |
806 |
sql.Append(" , Scm.DisplayOrder as DisplayOrder ");
|
800 |
|
sql.Append(" , Bdd.CONSTRUCTIONCODE as CONSTRUCTIONCODE ");
|
801 |
|
sql.Append(" , Bdd.FIELDNAME as FIELDNAME ");
|
802 |
|
sql.Append(" , Bdd.BILLPRICE as BILLPRICE ");
|
803 |
|
sql.Append(" , Bdd.HIGHWPRICE as HIGHWPRICE ");
|
804 |
|
sql.Append(" , Bdd.HARDWPRICE as HARDWPRICE ");
|
805 |
|
sql.Append(" , Bdd.INDSWASTETAX as INDSWASTETAX ");
|
|
807 |
sql.Append(" , Bdd.ConstructionCode as ConstructionCode ");
|
|
808 |
sql.Append(" , Bdd.FieldName as FieldName ");
|
|
809 |
sql.Append(" , Bdd.BillPrice as BillPrice ");
|
|
810 |
sql.Append(" , Bdd.HighwPrice as HighwPrice ");
|
|
811 |
sql.Append(" , Bdd.HardwPrice as HardwPrice ");
|
|
812 |
sql.Append(" , Bdd.IndswasteTax as IndswasteTax ");
|
806 |
813 |
sql.Append(" , DATE_FORMAT(Bdd.UpdateDate, '%Y/%m/%d %H:%i:%s') as UpdateDate ");
|
807 |
814 |
sql.Append(" , ifnull(Bdd.Note, '') as Bikou ");
|
808 |
|
sql.Append(" , ifnull(Pdd.BILLPRICE, 0) as KojiSeikyu ");
|
|
815 |
sql.Append(" , ifnull(Pdd.BillPrice, 0) as KojiSeikyu ");
|
809 |
816 |
sql.Append(" , ifnull(Pdd.DiscountPrice, 0) as KojiNebiki ");
|
810 |
817 |
sql.Append(" , ifnull(Pdd.OffsetPrice, 0) as KojiSousai ");
|
811 |
818 |
sql.Append(" , ifnull(Pdd.NextCoPrice, 0) as JikaiKurikosi ");
|
812 |
|
sql.Append(" , ifnull(Pdd.HIGHWPRICE, 0) as KojiKousoku ");
|
813 |
|
sql.Append(" , ifnull(Pdd.HARDWPRICE, 0) as KojiKanamono ");
|
814 |
|
sql.Append(" , ifnull(Pdd.INDSWASTETAX, 0) as KojiSannhaiZei ");
|
|
819 |
sql.Append(" , ifnull(Pdd.HighwPrice, 0) as KojiKousoku ");
|
|
820 |
sql.Append(" , ifnull(Pdd.HardwPrice, 0) as KojiKanamono ");
|
|
821 |
sql.Append(" , ifnull(Pdd.IndswasteTax, 0) as KojiSannhaiZei ");
|
815 |
822 |
sql.Append(" , ifnull(Pdd.CnstrPrice, 0) as CnstrPrice ");
|
816 |
|
sql.Append(" , ifnull(Pdd.CNSTRPRICEEXIST, - 1) as CNSTRPRICEEXIST ");
|
|
823 |
sql.Append(" , ifnull(Pdd.CnstrPriceExist, - 1) as CnstrPriceExist ");
|
817 |
824 |
sql.Append(" , ifnull(Pdd.ApprovalPersonCode, 0) as ApprovalPersonCode ");
|
818 |
825 |
sql.Append(" , ifnull(Picm.SealPrintName, '') as TantoNM ");
|
819 |
826 |
sql.Append(" , DATE_FORMAT( ");
|
... | ... | |
826 |
833 |
sql.Append(" , ifnull(Cbi.ConstrSubPersonCode, 0) as ConstrSubPersonCode ");
|
827 |
834 |
sql.Append(" , ifnull(Cbi.ConstructionInstructor, 0) as ConstructionInstructor ");
|
828 |
835 |
sql.Append(" , Picm2.DepartmentCode ");
|
829 |
|
sql.Append(" , case ifnull(Cbi.PurchaseOrderMailingDate, '') ");
|
830 |
|
sql.Append(" when '' then '' ");
|
|
836 |
sql.Append(" , case ifnull(Pod.SendDate, '') ");
|
|
837 |
sql.Append(" when '' then '?~' ");
|
831 |
838 |
sql.Append(" when '2001/01/01' then '?~' ");
|
832 |
839 |
sql.Append(" else '??' ");
|
833 |
840 |
sql.Append(" end as PurchaseOrderMailingDate ");
|
834 |
|
sql.Append(" , case ifnull(Cbi.PurchaseOrderReturnDate, '') ");
|
835 |
|
sql.Append(" when '' then '' ");
|
|
841 |
sql.Append(" , case ifnull(Pod.ReturnCheckDate, '') ");
|
|
842 |
sql.Append(" when '' then '?~' ");
|
836 |
843 |
sql.Append(" when '2001/01/01' then '?~' ");
|
837 |
844 |
sql.Append(" else '??' ");
|
838 |
845 |
sql.Append(" end as PurchaseOrderReturnDate ");
|
839 |
|
sql.Append(" , case ifnull(Pa.PERSONCODE, 0) ");
|
840 |
|
sql.Append(" when 0 then case Bdd.CONSTRUCTIONCODE ");
|
|
846 |
sql.Append(" , case ifnull(Pa.PersonCode, 0) ");
|
|
847 |
sql.Append(" when 0 then case Bdd.ConstructionCode ");
|
841 |
848 |
sql.Append(" when 0 then '' ");
|
842 |
849 |
sql.Append(" else '?~' ");
|
843 |
850 |
sql.Append(" end ");
|
... | ... | |
848 |
855 |
sql.Append("from ");
|
849 |
856 |
sql.Append(" BillingData as Bd join ( ");
|
850 |
857 |
sql.Append(" BillingDataDetail as Bdd join SubContractorMaster as Scm ");
|
851 |
|
sql.Append(" on Bdd.COMPANYCODE = Scm.COMPANYCODE ");
|
852 |
|
sql.AppendFormat(" and Scm.LABOURKIND = {0} ", m_Labourkind);
|
|
858 |
sql.Append(" on Bdd.CompanyCode = Scm.CompanyCode ");
|
|
859 |
sql.AppendFormat(" and Scm.LabourKind = {0} ", m_Labourkind);
|
853 |
860 |
sql.Append(" left join ( ");
|
854 |
861 |
sql.Append(" PaymentDataDetail as Pdd ");
|
855 |
862 |
sql.Append(" left join PersonInChargeMaster as Picm ");
|
856 |
|
sql.Append(" on ifnull(Pdd.ApprovalPersonCode, - 1) = Picm.PERSONCODE ");
|
|
863 |
sql.Append(" on ifnull(Pdd.ApprovalPersonCode, - 1) = Picm.PersonCode ");
|
857 |
864 |
sql.Append(" ) ");
|
858 |
|
sql.Append(" on Bdd.COMPANYCODE = Pdd.COMPANYCODE ");
|
859 |
|
sql.Append(" and Bdd.TARGETDATE = Pdd.TARGETDATE ");
|
860 |
|
sql.Append(" and Bdd.SEQNO = Pdd.SEQNO ");
|
861 |
|
sql.Append(" and Bdd.LINECOUNT = Pdd.LINECOUNT ");
|
|
865 |
sql.Append(" on Bdd.CompanyCode = Pdd.CompanyCode ");
|
|
866 |
sql.Append(" and Bdd.TargetDate = Pdd.TargetDate ");
|
|
867 |
sql.Append(" and Bdd.SeqNo = Pdd.SeqNo ");
|
|
868 |
sql.Append(" and Bdd.LineCount = Pdd.LineCount ");
|
862 |
869 |
sql.Append(" left join ( ");
|
863 |
870 |
sql.Append(" ConstructionBaseInfo as Cbi ");
|
864 |
871 |
sql.Append(" left join ( ");
|
865 |
872 |
sql.Append(" PersonInChargeMaster as Picm2 ");
|
866 |
873 |
sql.Append(" left join ApprovalMaster as Am ");
|
867 |
|
sql.Append(" on Picm2.DEPARTMENTCODE = Am.DEPARTMENTCODE ");
|
|
874 |
sql.Append(" on Picm2.DepartmentCode = Am.DepartmentCode ");
|
868 |
875 |
sql.Append(" and Am.ApprovalCode = 3 ");
|
869 |
876 |
sql.Append(" and ApprovalAuthority = 1 ");
|
870 |
877 |
sql.Append(" ) ");
|
871 |
|
sql.Append(" on Cbi.ConstructionPersonCode = Picm2.PERSONCODE ");
|
|
878 |
sql.Append(" on Cbi.ConstructionPersonCode = Picm2.PersonCode ");
|
872 |
879 |
sql.Append(" left join ProcessApproval as Pa ");
|
873 |
|
sql.Append(" on Cbi.CONSTRUCTIONCODE = Pa.CONSTRUCTIONCODE ");
|
874 |
|
sql.Append(" and Am.APPROVALPERSON = Pa.PERSONCODE ");
|
875 |
|
sql.Append(" and Pa.SEQNO > 1 ");
|
876 |
|
sql.Append(" and Pa.APPROVALSTATUS = 2 ");
|
|
880 |
sql.Append(" on Cbi.ConstructionCode = Pa.ConstructionCode ");
|
|
881 |
sql.Append(" and Am.ApprovalPerson = Pa.PersonCode ");
|
|
882 |
sql.Append(" and Pa.SeqNo > 1 ");
|
|
883 |
sql.Append(" and Pa.ApprovalStatus = 2 ");
|
877 |
884 |
sql.Append(" ) ");
|
878 |
|
sql.Append(" on Bdd.CONSTRUCTIONCODE = Cbi.CONSTRUCTIONCODE ");
|
|
885 |
sql.Append(" on Bdd.ConstructionCode = Cbi.ConstructionCode ");
|
879 |
886 |
sql.Append(" ) ");
|
880 |
|
sql.Append(" on Bd.COMPANYCODE = BdD.COMPANYCODE ");
|
881 |
|
sql.Append(" and Bd.TARGETDATE = BdD.TARGETDATE ");
|
882 |
|
sql.Append(" and Bd.SEQNO = BdD.SEQNO ");
|
883 |
|
sql.AppendFormat(" and Bd.TARGETDATE = {0} ", m_Select_TargetDate);
|
|
887 |
sql.Append(" on Bd.CompanyCode = Bdd.CompanyCode ");
|
|
888 |
sql.Append(" and Bd.TargetDate = Bdd.TargetDate ");
|
|
889 |
sql.Append(" and Bd.SeqNo = Bdd.SeqNo ");
|
|
890 |
sql.AppendFormat(" and Bd.TargetDate = {0} ", m_Select_TargetDate);
|
884 |
891 |
sql.Append(" and Bdd.CONSTRUCTIONCODE = 0 ");
|
|
892 |
sql.Append(" left join ( ");
|
|
893 |
sql.Append(" PurchaseOrderDate as Pod ");
|
|
894 |
sql.Append(" ) on Bd.CompanyCode = Pod.CompanyCode ");
|
|
895 |
sql.Append(" and Bdd.ConstructionCode = Pod.ConstructionCode ");
|
|
896 |
|
885 |
897 |
sql.Append(" ");
|
|
898 |
|
886 |
899 |
sql.Append("group by ");
|
887 |
|
sql.Append(" SEQNO ");
|
888 |
|
sql.Append(" , LINECOUNT ");
|
889 |
|
sql.Append(" , COMPANYCODE ");
|
890 |
|
sql.Append(" , COMPANYNAME ");
|
|
900 |
sql.Append(" SeqNo ");
|
|
901 |
sql.Append(" , LineCount ");
|
|
902 |
sql.Append(" , CompanyCode ");
|
|
903 |
sql.Append(" , CompanyName ");
|
891 |
904 |
sql.Append(" , DisplayOrder ");
|
892 |
|
sql.Append(" , CONSTRUCTIONCODE ");
|
893 |
|
sql.Append(" , FIELDNAME ");
|
894 |
|
sql.Append(" , BILLPRICE ");
|
895 |
|
sql.Append(" , HIGHWPRICE ");
|
896 |
|
sql.Append(" , HARDWPRICE ");
|
897 |
|
sql.Append(" , INDSWASTETAX ");
|
|
905 |
sql.Append(" , ConstructionCode ");
|
|
906 |
sql.Append(" , FieldName ");
|
|
907 |
sql.Append(" , BillPrice ");
|
|
908 |
sql.Append(" , HighwPrice ");
|
|
909 |
sql.Append(" , Hardwprice ");
|
|
910 |
sql.Append(" , IndswasteTax ");
|
898 |
911 |
sql.Append(" , UpdateDate ");
|
899 |
912 |
sql.Append(" , Bikou ");
|
900 |
|
sql.Append(" , BILLPRICE ");
|
901 |
|
sql.Append(" , DiscountPrice ");
|
902 |
|
sql.Append(" , OffsetPrice ");
|
903 |
|
sql.Append(" , NextCoPrice ");
|
904 |
|
sql.Append(" , HIGHWPRICE ");
|
905 |
|
sql.Append(" , HARDWPRICE ");
|
906 |
|
sql.Append(" , INDSWASTETAX ");
|
|
913 |
sql.Append(" , KojiSeikyu ");
|
|
914 |
sql.Append(" , KojiNebiki ");
|
|
915 |
sql.Append(" , KojiSousai ");
|
|
916 |
sql.Append(" , JikaiKurikosi ");
|
|
917 |
sql.Append(" , KojiKousoku ");
|
|
918 |
sql.Append(" , KojiKanamono ");
|
|
919 |
sql.Append(" , KojiSannhaiZei ");
|
907 |
920 |
sql.Append(" , CnstrPrice ");
|
908 |
|
sql.Append(" , CNSTRPRICEEXIST ");
|
|
921 |
sql.Append(" , CnstrpriceExist ");
|
909 |
922 |
sql.Append(" , ApprovalPersonCode ");
|
910 |
923 |
sql.Append(" , TantoNM ");
|
911 |
924 |
sql.Append(" , ApprovalDate ");
|
... | ... | |
923 |
936 |
|
924 |
937 |
if (dgvCompany.Visible == true) // ???P??\??
|
925 |
938 |
{
|
926 |
|
sql.AppendLine("order by COMPANYCODE ASC, SEQNO DESC, case when CONSTRUCTIONCODE = 0 Then 2099999999 else LINECOUNT end ");
|
|
939 |
sql.AppendLine("order by CompanyCode ASC, SeqNo DESC, case when ConstructionCode = 0 Then 2099999999 else LineCount end ");
|
927 |
940 |
}
|
928 |
941 |
else if (dgvProject.Visible == true) // ????P??\??
|
929 |
942 |
{
|
930 |
|
sql.AppendLine("order by ConstructionPersonCode ASC, CONSTRUCTIONCODE DESC, DISPLAYORDER ASC, SEQNO ASC, LINECOUNT ASC ");
|
|
943 |
sql.AppendLine("order by ConstructionPersonCode ASC, ConstructionCode DESC, DisplayOrder ASC, SEQNO ASC, LineCount ASC ");
|
931 |
944 |
}
|
932 |
945 |
|
933 |
946 |
// ?f?[?^???@???v?E???v???v?Z?????A?S???f?[?^????????
|