예제 #1
0
        public CDTData GetDataForDetailReport(string linkfield, string linkitem)
        {
            string    s  = "select * from sysReport where sysReportParentID = " + _drTable["SysReportID"].ToString();
            DataTable dt = _dbStruct.GetDataTable(s);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(null);
            }
            CDTData data = CusData.Create(DataType.Report, dt.Rows[0]);

            data.GetData();
            //Chuyển data cha qua data con
            DataRow dr = data.DsData.Tables[0].NewRow();

            foreach (DataColumn dc in DsData.Tables[0].Columns)
            {
                if (data.DsData.Tables[0].Columns[dc.ColumnName] == null)
                {
                    continue;
                }
                dr[dc.ColumnName] = DsData.Tables[0].Rows[0][dc.ColumnName];
            }
            if (!(data.DsData.Tables[0].Columns[linkfield] == null))
            {
                dr[linkfield] = linkitem.Trim();
            }
            data.DsData.Tables[0].Rows.Add(dr);
            //this.GenFilterString();
            return(data);
        }
예제 #2
0
        public CDTData GetFormForReport()
        {
            string    sysReportID  = _drTable["sysReportID"].ToString();
            string    sysPackageID = Config.GetValue("sysPackageID").ToString();
            DataTable dtTable      = _dbStruct.GetDataTable("select * from sysTable where TableName = 'sysFormReport' and sysPackageID = " + sysPackageID);
            CDTData   data         = CusData.Create(DataType.Single, dtTable.Rows[0]);

            data.Condition = "sysReportID = " + sysReportID;
            return(data);
        }
예제 #3
0
        public void GetData(CDTData ParentData)
        {
            ConditionForPackage();
            string extrasql = string.Empty;

            if (_drTable.Table.Columns.Contains("ExtraSql"))
            {
                if (_drTable["ExtraSql"] != null)
                {
                    extrasql = _drTable["Extrasql"].ToString();
                }
            }

            string queryData = "select * from " + _drTable["TableName"].ToString();

            if (_condition != string.Empty && !(_condition.Contains("@")))
            {
                queryData += " where " + _condition;
                if (extrasql != string.Empty)
                {
                    queryData += " and (" + extrasql + ")";
                }
            }
            else
            if (extrasql != string.Empty)
            {
                queryData += " where " + extrasql;
            }

            string lkCondition = GenConditionForLookup(ParentData);

            if (lkCondition != string.Empty)
            {
                if (_condition == string.Empty && extrasql == string.Empty)
                {
                    queryData += " where " + lkCondition;
                }
                else
                {
                    queryData += " and ( " + lkCondition + ")";
                }
            }

            if (_drTable["SortOrder"].ToString() != string.Empty)
            {
                queryData += " order by " + DrTable["SortOrder"].ToString();
            }

            DsData = DbData.GetDataSet(queryData);
            if (DsData != null)
            {
                _dsDataTmp = DsData.Copy();
            }
        }
예제 #4
0
        public CDTData GetDataForVoucher(string maCT, string linkItem)
        {
            string    sysReportID  = _drTable["sysReportID"].ToString();
            string    sysPackageID = Config.GetValue("sysPackageID").ToString();
            string    s            = "select * from sysTable where MaCT = '" + maCT + "' and sysPackageID = " + sysPackageID;
            DataTable dt           = _dbStruct.GetDataTable(s);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(null);
            }
            CDTData data = CusData.Create(DataType.MasterDetail, dt.Rows[0]);

            data.ConditionMaster = data.DrTableMaster["Pk"].ToString() + " = '" + linkItem + "'";
            data.GetData();
            return(data);
        }
예제 #5
0
        public static CDTData Create(DataType type, string TableName, string sysPackageID)
        {
            CDTData tmp = null;

            switch (type)
            {
            case DataType.Detail:
                tmp = new DataDetail(TableName, sysPackageID);
                break;

            case DataType.MasterDetail:
                tmp = new DataMasterDetail(TableName, sysPackageID);
                break;

            case DataType.Single:
                tmp = new DataSingle(TableName, sysPackageID);
                break;
            }
            return(tmp);
        }
예제 #6
0
        private void refreshLookup()
        {
            for (int i = 0; i < _gv.Columns.Count; i++)
            {
                GridColumn       g = _gv.Columns[i];
                CDTRepGridLookup r = (g.ColumnEdit as CDTRepGridLookup);
                if (r != null)
                {
                    if (r.Tag != null)
                    {
                        if (r.Tag.ToString() != string.Empty)
                        {
                            BindingSource bstmp    = r.DataSource as BindingSource;
                            CDTData       rdatatmp = r.Buttons[1].Tag as CDTData;
                            if (!rdatatmp.FullData)
                            {
                                rdatatmp.GetData();
                                bstmp.DataSource  = rdatatmp.DsData.Tables[0];
                                r.DataSource      = bstmp;
                                rdatatmp.FullData = true;

                                for (int j = i + 1; j < _gv.Columns.Count; j++)
                                {
                                    if (_gv.Columns[j].FieldName.ToLower() == g.FieldName.ToLower())
                                    {
                                        CDTRepGridLookup rj  = (_gv.Columns[j].ColumnEdit as CDTRepGridLookup);
                                        BindingSource    bsj = rj.DataSource as BindingSource;
                                        bsj.DataSource = rdatatmp.DsData.Tables[0];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        public static CDTData Create(DataType type, DataRow drTable)
        {
            CDTData tmp = null;

            switch (type)
            {
            case DataType.Detail:
                tmp = new DataDetail(drTable);
                break;

            case DataType.MasterDetail:
                tmp = new DataMasterDetail(drTable);
                break;

            case DataType.Single:
                tmp = new DataSingle(drTable);
                break;

            case DataType.Report:
                tmp = new DataReport(drTable);
                break;
            }
            return(tmp);
        }
예제 #8
0
 public void GetDataForLookup(CDTData ParentData)
 {
     (this as DataSingle).GetData(ParentData);
 }
예제 #9
0
        private string GenConditionForLookup(CDTData ParentData)
        {
            string s         = string.Empty;
            string tableName = _drTable["TableName"].ToString().ToUpper();

            foreach (DataRow drField in ParentData.DsStruct.Tables[0].Rows)
            {
                string refTable = drField["RefTable"].ToString().ToUpper();
                if (refTable == string.Empty || tableName != refTable)
                {
                    continue;
                }
                if (s == string.Empty)
                {
                    s = drField["refField"].ToString() + " in (";
                }
                string fieldName = drField["FieldName"].ToString();
                //if (fieldName.ToUpper() == "REFTABLE" || fieldName.ToUpper() == "REFFIELD")
                //    continue;
                int n = ParentData.DsData.Tables[0].Rows.Count;
                for (int i = 0; i < n; i++)
                {
                    DataRow drData = ParentData.DsData.Tables[0].Rows[i];
                    if (drData[fieldName].ToString() == string.Empty)
                    {
                        continue;
                    }
                    string newValue = "'" + drData[fieldName].ToString() + "'";
                    if (!s.Contains(newValue))
                    {
                        s += newValue + ",";
                    }
                }
            }
            if (s.EndsWith(","))
            {
                s = s.Remove(s.Length - 1);
            }
            if (ParentData.DsData.Tables.Count == 1 || ParentData.DsData.Tables[1].Rows.Count == 0)
            {
                if (s.EndsWith("(") || s == string.Empty)
                {
                    s = "1 = 0";
                }
                else
                {
                    s += ")";
                }
                return(s);
            }
            bool first = true;

            foreach (DataRow drField in ParentData.DsStruct.Tables[1].Rows)
            {
                string refTable = drField["RefTable"].ToString().ToUpper();
                if (refTable == string.Empty || tableName != refTable)
                {
                    continue;
                }
                if (s == string.Empty)
                {
                    s = drField["refField"].ToString() + " in (";
                }
                string fieldName = drField["FieldName"].ToString();
                //if (fieldName.ToUpper() == "REFTABLE" || fieldName.ToUpper() == "REFFIELD")
                //    continue;
                int n = ParentData.DsData.Tables[1].Rows.Count;
                if (first && n > 0 && !s.EndsWith("("))
                {
                    s += ",";
                }
                first = false;
                for (int i = 0; i < n; i++)
                {
                    DataRow drData = ParentData.DsData.Tables[1].Rows[i];
                    if (drData[fieldName].ToString() == string.Empty)
                    {
                        continue;
                    }
                    string newValue = "'" + drData[fieldName].ToString() + "'";
                    if (!s.Contains(newValue))
                    {
                        s += newValue + ",";
                    }
                }
            }
            if (s.EndsWith(","))
            {
                s = s.Remove(s.Length - 1);
            }
            if (s.EndsWith("(") || s == string.Empty)
            {
                s = "1 = 0";
            }
            else
            {
                s += ")";
            }
            return(s);
        }