using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Core.XgMes.Client.JGKC.RollManager
{
    public partial class UCSendStatJB : UserControl
    {
        public UCSendStatJB()
        {
            InitializeComponent();
        }
        #region "Property
        private string _SelectStr = "SELECT ZSLAB_WEIGHT WEIGHT  ,XJJL_WEIGHT ";//A.STEELTYPE
        private string _FromStr = " FROM KCJ3_TURNOFFSENDLIST_ZW A,TBA01_ORD_LINE B,tbz00_customer  C,tbz00_commcd D ,TBA01_ORD_COMM E "
                                 + " WHERE A.ISVALID<>'0'  AND A.ORD_NO  = E.ORD_NO  "
                                 + " AND E.CUST_CD = C.CUST_CD(+) AND B.DEST_PCD = D.SM_CD(+)   AND A.ORD_NO || A.ORD_SEQ=B.ORD_NO || B.ORD_SEQ  ";

        private string _GroupbyStr = " GROUP BY a.ZSLAB_WEIGHT,XJJL_WEIGHT";
        public System.Collections.ArrayList SendSelectStr
        {
            get
            {
                System.Collections.ArrayList rtnList = new System.Collections.ArrayList();
                string rtnStr = _SelectStr;


                if (this.chk_StatInceName.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",C.CUST_NM INCEPTCORPNAME";
                    }
                    else
                    {
                        rtnStr = rtnStr + "C.CUST_NM INCEPTCORPNAME";
                    }
                }
                if (this.Chk_StatListCoding.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.LISTNUMBER";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.LISTNUMBER";
                    }
                }
                if (this.chk_zl.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.CAL_WGT";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.CAL_WGT";
                    }
                }
                if (this.Chk_StatVecihleNO.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.TRANS_CAR_NO TRAINWAGON";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.TRANS_CAR_NO TRAINWAGON";
                    }
                }
             
                
             
                if (this.chk_StatStation.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",D.SM_CFNM STATIONNAME";
                    }
                    else
                    {
                        rtnStr = rtnStr + "D.SM_CFNM STATIONNAME";
                    }
                }
                if (this.Chk_StatPactNO.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",B.ORD_NO PACTNO";
                    }
                    else
                    {
                        rtnStr = rtnStr + "B.ORD_NO PACTNO";
                    }
                }
                if (this.chk_StatOrder.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.ORD_NO || A.ORD_SEQ ORDERFORMNUMBER";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.ORD_NO || A.ORD_SEQ ORDERFORMNUMBER";
                    }
                }
                //钢卷号
                if (this.Chk_StatPlanNO.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.OLD_SAMPL_NO";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.OLD_SAMPL_NO";
                    }
                }
                if (this.Chk_StatSteel.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.STL_GRD STEELTYPE";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.STL_GRD STEELTYPE";
                    }
                }
                //钢卷包号
                if (this.Chk_StatRollNO.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.COIL_NO_ID";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.COIL_NO_ID";
                    }
                }
                if (this.Chk_StatClassTeam.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=A.CLASSTEAM) CLASSTEAM";
                    }
                    else
                    {
                        rtnStr = rtnStr + "(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=A.CLASSTEAM) CLASSTEAM";
                    }
                }
                //if (this.Chk_StatDeteMar.Checked)
                //{
                //    if (rtnStr.Length > 7)
                //    {
                //        rtnStr = rtnStr + ",(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=B.ISCHECKSCAR) ISCHECKSCAR,DECODE(B.ISHEAT,'1','√',NULL) ISHEAT";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=B.ISCHECKSCAR) ISCHECKSCAR,DECODE(B.ISHEAT,'1','√',NULL) ISHEAT";
                //    }
                //}
                //if (this.Chk_StatRole.Checked)
                //{
                //    if (rtnStr.Length > 7)
                //    {
                //        rtnStr = rtnStr + ",(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=A.ROLE) ROLE";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=A.ROLE) ROLE";
                //    }
                //}
                //if (this.Chk_StatCondole.Checked)
                //{
                //    if (rtnStr.Length > 7)
                //    {
                //        rtnStr = rtnStr + ",A.CONDOLENUMBER";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "A.CONDOLENUMBER";
                //    }
                //}
                //if (this.Chk_StatResult.Checked)
                //{
                //    if (rtnStr.Length > 7)
                //    {
                //        rtnStr = rtnStr + ",(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=A.DETERMINANTRESULT) DETERMINANTRESULT";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=A.DETERMINANTRESULT) DETERMINANTRESULT";
                //    }
                //}
                if (this.Chk_StatSendDate.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD') PICKSTORAGETIME";
                    }
                    else
                    {
                        rtnStr = rtnStr + "TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD') PICKSTORAGETIME";
                    }
                }
                if (this.Chk_StatBookInDate.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",TO_CHAR(A.CREATETIME,'YY-MM-DD HH24:MI') CREATTIME";
                    }
                    else
                    {
                        rtnStr = rtnStr + "TO_CHAR(A.CREATETIME,'YY-MM-DD HH24:MI') CREATTIME";
                    }
                }
                if (this.Chk_StatBookInMan.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.CREATOR";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.CREATOR";
                    }
                }
                if (this.Chk_StatSendMan.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.PICKSTORAGEMAN";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.PICKSTORAGEMAN";
                    }
                }
               
                    rtnStr = rtnStr + _FromStr;
                    rtnList.Add(rtnStr);
                    return rtnList;
                
            //    if (this.Chk_StatBilletID.Checked)
            //    {
            //        if (rtnStr.Length > 7)
            //        {
            //            rtnStr = rtnStr + ",A.SERIALNUMBER,1 QUANTITY,A.WEIGHT,A.ADDWEIGHT,A.ACREAGE ";
            //        }
            //        else
            //        {
            //            rtnStr = rtnStr + "C.INCEPTCORPNAME,A.LISTNUMBER,A.STEELTYPE,TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD') PICKSTORAGETIME,A.SERIALNUMBER,1 QUANTITY,A.WEIGHT,A.ADDWEIGHT,A.ACREAGE ";
            //        }
            //        rtnStr = rtnStr + ",TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH)||'×'||TO_CHAR(A.LENGTH) SPET";
            //        rtnStr = rtnStr + _FromStr;
            //        rtnList.Add(rtnStr);
            //        return rtnList;
            //    }
            //    else
            //    {
            //        if (rtnStr.Length > 7)
            //        {
            //            rtnStr = rtnStr + ",COUNT(A.SERIALNUMBER) QUANTITY,SUM(A.WEIGHT) WEIGHT,SUM(A.ADDWEIGHT) ADDWEIGHT,SUM(A.ACREAGE) ACREAGE ";
            //        }
            //        else
            //        {
            //            rtnStr = rtnStr + "C.INCEPTCORPNAME,A.LISTNUMBER,A.STEELTYPE,TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD') PICKSTORAGETIME,COUNT(A.SERIALNUMBER) QUANTITY,SUM(A.WEIGHT) WEIGHT,SUM(A.ADDWEIGHT) ADDWEIGHT,SUM(A.ACREAGE) ACREAGE ";
            //        }
            //    }
            //    if (this.Chk_StatRole.Checked)
            //    {
            //        string tmpstr = "";
            //        tmpstr = rtnStr + ",TO_CHAR(A.PLY)||'×'||TO_CHAR(A.LENGTH) SPET ";       //定长
            //        tmpstr = tmpstr + _FromStr + " AND A.ROLE='102201' ";
            //        rtnList.Add(tmpstr);
            //        tmpstr = rtnStr + ",TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH) SPET ";      //定宽
            //        tmpstr = tmpstr + _FromStr + " AND (A.ROLE='102202' OR A.ROLE='102206') ";
            //        rtnList.Add(tmpstr);
            //        tmpstr = rtnStr + ",TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH)||'×'||TO_CHAR(A.LENGTH) SPET ";      //双定
            //        tmpstr = tmpstr + _FromStr + " AND (A.ROLE='102203' OR A.ROLE IS NULL) ";
            //        rtnList.Add(tmpstr);
            //        tmpstr = rtnStr + ",TO_CHAR(A.PLY) SPET ";      //非定
            //        tmpstr = tmpstr + _FromStr + " AND (A.ROLE='102204' OR A.ROLE='102205') ";
            //        rtnList.Add(tmpstr);
            //        return rtnList;
            //    }
            //    else
            //    {
            //        if (this.Chk_StatSpet.Checked)
            //        {
            //            rtnStr = rtnStr + ",TO_CHAR(A.PLY) SPET ";
            //        }
            //        rtnStr = rtnStr + _FromStr;
            //        rtnList.Add(rtnStr);
            //        return rtnList;
            //    }
            }
        }
        public System.Collections.ArrayList SendGroupbyStr
        {
            get
            {
                System.Collections.ArrayList rtnList =new System.Collections.ArrayList();
                string rtnStr = _GroupbyStr;

               

                if (this.chk_StatInceName.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",C.CUST_NM ";
                    }
                    else
                    {
                        rtnStr = rtnStr + "C.CUST_NM ";
                    }
                }
                if (this.Chk_StatListCoding.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.LISTNUMBER";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.LISTNUMBER";
                    }
                }
             
                if (this.Chk_StatVecihleNO.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.TRANS_CAR_NO";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.TRANS_CAR_NO";
                    }
                }
             
                if (this.chk_StatStation.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",D.SM_CFNM ";
                    }
                    else
                    {
                        rtnStr = rtnStr + "D.SM_CFNM ";
                    }
                }
                if (this.chk_zl.Checked)
                {
                    if (rtnStr.Length > 7)
                    {
                        rtnStr = rtnStr + ",A.CAL_WGT";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.CAL_WGT";
                    }
                }
                if (this.Chk_StatPactNO.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",B.ORD_NO  ";
                    }
                    else
                    {
                        rtnStr = rtnStr + "B.ORD_NO ";
                    }
                }
                if (this.chk_StatOrder.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.ORD_NO || A.ORD_SEQ  ";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.ORD_NO || A.ORD_SEQ  ";
                    }
                }
                if (this.Chk_StatPlanNO.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.OLD_SAMPL_NO";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.OLD_SAMPL_NO";
                    }
                }
                if (this.Chk_StatSteel.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.STL_GRD ";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.STL_GRD ";
                    }
                }
                if (this.Chk_StatRollNO.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.COIL_NO_ID";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.COIL_NO_ID";
                    }
                }
                if (this.Chk_StatClassTeam.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.CLASSTEAM";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.CLASSTEAM";
                    }
                }
                //if (this.Chk_StatDeteMar.Checked)
                //{
                //    if (rtnStr.Length > 10)
                //    {
                //        rtnStr = rtnStr + ",B.ISCHECKSCAR,B.ISHEAT";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "B.ISCHECKSCAR,B.ISHEAT";
                //    }
                //}
                //if (this.Chk_StatRole.Checked)
                //{
                //    if (rtnStr.Length > 10)
                //    {
                //        rtnStr = rtnStr + ",A.ROLE";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "A.ROLE";
                //    }
                //}
                //if (this.Chk_StatCondole.Checked)
                //{
                //    if (rtnStr.Length > 10)
                //    {
                //        rtnStr = rtnStr + ",A.CONDOLENUMBER";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "A.CONDOLENUMBER";
                //    }
                //}
                //if (this.Chk_StatResult.Checked)
                //{
                //    if (rtnStr.Length > 10)
                //    {
                //        rtnStr = rtnStr + ",A.DETERMINANTRESULT";
                //    }
                //    else
                //    {
                //        rtnStr = rtnStr + "A.DETERMINANTRESULT";
                //    }
                //}
                if (this.Chk_StatSendDate.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD')";
                    }
                    else
                    {
                        rtnStr = rtnStr + "TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD')";
                    }
                }
                if (this.Chk_StatBookInDate.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",TO_CHAR(A.CREATETIME,'YY-MM-DD HH24:MI')";
                    }
                    else
                    {
                        rtnStr = rtnStr + "TO_CHAR(A.CREATETIME,'YY-MM-DD HH24:MI')";
                    }
                }
                if (this.Chk_StatBookInMan.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.CREATOR";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.CREATOR";
                    }
                }
                if (this.Chk_StatSendMan.Checked)
                {
                    if (rtnStr.Length > 10)
                    {
                        rtnStr = rtnStr + ",A.PICKSTORAGEMAN";
                    }
                    else
                    {
                        rtnStr = rtnStr + "A.PICKSTORAGEMAN";
                    }
                }
                    //rtnStr = rtnStr + _FromStr;
                    rtnList.Add(rtnStr);
                    return rtnList;
              
                //if (this.Chk_StatBilletID.Checked)
                //{
                //    rtnStr = "";
                //    rtnList.Add("");
                //    return rtnList;
                //}
                //else
                //{
                //    if (rtnStr.Length <= 10)
                //    {
                //        rtnStr = rtnStr + "C.INCEPTCORPNAME,A.LISTNUMBER,A.STEELTYPE,TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD')";
                //    }
                //}
                //if (this.Chk_StatRole.Checked)
                //{
                //    string tmpstr = "";
                //    tmpstr = rtnStr + ",A.PLY,A.LENGTH";
                //    rtnList.Add(tmpstr);
                //    tmpstr = rtnStr + ",A.PLY,A.WIDTH";
                //    rtnList.Add(tmpstr);
                //    tmpstr = rtnStr + ",A.PLY,A.WIDTH,A.LENGTH";
                //    rtnList.Add(tmpstr);
                //    tmpstr = rtnStr + ",A.PLY";
                //    rtnList.Add(tmpstr);
                //    return rtnList;
                //}
                //else
                //{
                //    if (this.Chk_StatSpet.Checked)
                //    {
                //        rtnStr = rtnStr + ",A.PLY";
                //    }
                //    rtnList.Add(rtnStr);
                //    return rtnList;
                //}
            }
        }
  
       
        #endregion
    }
}
