public void SaveRelation()
        {
            System.Data.DataTable dt = m_dtRelation.Clone();
            for (int i1 = 0; i1 < this.m_objViewer.m_dgRelation.RowCount; i1++)
            {
                if (this.m_objViewer.m_dgRelation[i1, 0].ToString() != "")
                {
                    System.Data.DataRow newRow = dt.NewRow();
                    newRow["medicinetypeid_chr"] = this.m_objViewer.m_dgRelation[i1, 4].ToString();
                    newRow["itemcatid_chr"]      = this.m_objViewer.m_dgRelation[i1, 5].ToString();
                    newRow["OUTMEDSTOREID_CHR"]  = this.m_objViewer.m_dgRelation[i1, 6].ToString();
                    newRow["INMEDSTOREID_CHR"]   = this.m_objViewer.m_dgRelation[i1, 7].ToString();
                    dt.Rows.Add(newRow);
                }
            }
            long lngRes = objSvc.m_lngSaveFeeAndMedSortRel(dt, this.m_dtDel);

            if (lngRes > 0)
            {
                MessageBox.Show("保存成功");
            }
            else
            {
                MessageBox.Show("保存失败");
            }
        }
        /// <summary>
        /// 读入数据
        /// </summary>
        /// <param name="searchExpression"></param>
        /// <param name="searchOrders"></param>
        protected override void GetDataCount(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders)
        {
            System.Data.DataTable dt = DbHelper.Instance.ExecuteDataTable(CreateDbCommand(searchExpression, searchOrders));
            dt.TableName = m_tableName;

            if (this.EnablePage && m_dataCanPage)
            {
                base.Count = GetCount(searchExpression);
            }
            else
            {
                base.Count = dt.Rows.Count;
            }

            // 需要分页但数据库读取不能分页的时候,读出全部数据然后选择性返回
            if (this.EnablePage && !m_dataCanPage)
            {
                System.Data.DataTable dt2 = dt.Clone();
                for (int i = 0; i < Math.Min(dt.Rows.Count - this.FirstResult, this.MaxResult); ++i)
                {
                    dt2.ImportRow(dt.Rows[i + this.FirstResult]);
                }
                this.Result = dt2.DefaultView;
            }
            else
            {
                this.Result = dt.DefaultView;
            }
        }
Beispiel #3
0
        /// <summary>
        /// 根据查询条件读入数据
        /// </summary>
        /// <param name="searchExpression"></param>
        /// <param name="searchOrders"></param>
        protected override void GetDataCount(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders)
        {
            System.Data.DataTable dt = GetData(searchExpression, searchOrders) as System.Data.DataTable;

            if (this.EnablePage && m_dataCanPage)
            {
                base.Count = GetCount(searchExpression);
            }
            else
            {
                base.Count = dt.Rows.Count;
            }

            // 需要分页但数据库读取不能分页的时候,读出全部数据然后选择性返回
            if (this.EnablePage && !m_dataCanPage)
            {
                System.Data.DataTable dt2 = dt.Clone();
                for (int i = 0; i < Math.Min(dt.Rows.Count, this.MaxResult); ++i)
                {
                    dt2.ImportRow(dt.Rows[i + this.FirstResult]);
                }
                base.Result = dt2.DefaultView;
            }
            else
            {
                base.Result = dt.DefaultView;
            }
        }
Beispiel #4
0
        public QueryResult QueryProductEx(NeweggProductQueryFilter request)
        {
            int totalCount;
            int maxTotalCnt = 500;
            var dataTable   = ObjectFactory <IProductQueryDA> .Instance.QueryProductEx(request, out totalCount);

            ObjectFactory <ProductAppService> .Instance.ClearProduct(dataTable, ref totalCount);

            //分区处理导出全部的数据
            if (dataTable.Rows.Count > maxTotalCnt)
            {
                int index = dataTable.Rows.Count / maxTotalCnt;
                index += (dataTable.Rows.Count % maxTotalCnt > 0 ? 1 : 0);
                System.Data.DataTable dtTmp    = new System.Data.DataTable();
                System.Data.DataTable dtResult = new System.Data.DataTable();
                dtTmp = dataTable.Clone();
                for (int i = 0; i < index; i++)
                {
                    dtTmp.Rows.Clear();
                    for (int j = maxTotalCnt * i; j < maxTotalCnt * (i + 1); j++)
                    {
                        if (j >= dataTable.Rows.Count)
                        {
                            break;
                        }
                        dtTmp.ImportRow(dataTable.Rows[j]);
                    }
                    ObjectFactory <ProductAppService> .Instance.GetInventoryInfoByStock(dtTmp);

                    if (i == 0)
                    {
                        ObjectFactory <ProductAppService> .Instance.AddOtherData(dtTmp);

                        dtResult = dtTmp.Clone();
                    }
                    foreach (System.Data.DataRow r in dtTmp.Rows)
                    {
                        dtResult.ImportRow(r);
                    }
                }
                return(new QueryResult
                {
                    Data = dtResult,
                    TotalCount = totalCount
                });
            }
            else
            {
                ObjectFactory <ProductAppService> .Instance.GetInventoryInfoByStock(dataTable);

                ObjectFactory <ProductAppService> .Instance.AddOtherData(dataTable);

                return(new QueryResult
                {
                    Data = dataTable,
                    TotalCount = totalCount
                });
            }
        }
 /// <summary>
 /// DataGridViewSelectedRowsToDataTable
 /// </summary>
 /// <param name="dgv"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 public static System.Data.DataTable DataGridViewSelectedRowsToDataTable(System.Windows.Forms.DataGridView dgv, int index)
 {
     System.Data.DataTable TotalDT      = (System.Data.DataTable)dgv.DataSource;
     System.Data.DataTable gridSelectDT = TotalDT.Clone();
     System.Data.DataRow   dr           = TotalDT.Rows[index];
     gridSelectDT.ImportRow(dr);
     return(gridSelectDT);
 }
Beispiel #6
0
 /// <summary>
 /// 复制System.Data.DataTable数据
 /// </summary>
 public static System.Data.DataTable CloneData(this System.Data.DataTable table)
 {
     System.Data.DataTable newTable = table.Clone();
     foreach (System.Data.DataRow row in table.Rows)
     {
         newTable.Rows.Add(row.ItemArray);
     }
     return(newTable);
 }
        static void Main(string[] args)
        {
            string myConnectionStringMDB =
                "Provider=Microsoft.ACE.OLEDB.12.0;" +
                @"Data Source=C:\Users\Gord\Desktop\fromCE.mdb;";
            string myConnectionStringSQL =
                "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;" +
                @"Data Source=C:\__tmp\myData.sdf;";

            using (OleDbConnection conSQL = new OleDbConnection(),
                   conMDB = new OleDbConnection())
            {
                conSQL.ConnectionString = myConnectionStringSQL;
                conSQL.Open();
                conMDB.ConnectionString = myConnectionStringMDB;
                conMDB.Open();
                using (OleDbCommand cmdSQL = new OleDbCommand(),
                       cmdMDB = new OleDbCommand())
                {
                    cmdSQL.CommandType = System.Data.CommandType.Text;
                    cmdSQL.Connection  = conSQL;
                    cmdSQL.CommandText = "SELECT * FROM [Table1]";
                    var daSQL = new System.Data.OleDb.OleDbDataAdapter();
                    daSQL.SelectCommand = cmdSQL;
                    var dtSQL = new System.Data.DataTable();
                    daSQL.Fill(dtSQL);
                    System.Data.DataTable dtMDB = dtSQL.Clone();

                    foreach (System.Data.DataRow drSQL in dtSQL.Rows)
                    {
                        // .ImportRow() would import the row as "Unchanged", so create a new one
                        System.Data.DataRow drMDB = dtMDB.NewRow();
                        drMDB.ItemArray = drSQL.ItemArray;
                        dtMDB.Rows.Add(drMDB);
                    }
                    cmdMDB.CommandType = System.Data.CommandType.Text;
                    cmdMDB.Connection  = conMDB;
                    cmdMDB.CommandText = "INSERT INTO [Table1] ([ID], [Field 1]) VALUES (?, ?)";
                    cmdMDB.Parameters.Add("?", OleDbType.Integer, 1, "ID");
                    cmdMDB.Parameters.Add("?", OleDbType.VarWChar, 255, "Field 1");
                    var daMDB = new System.Data.OleDb.OleDbDataAdapter();
                    daMDB.InsertCommand = cmdMDB;
                    daMDB.Update(dtMDB);
                }
                conSQL.Close();
                conMDB.Close();
            }
            Console.WriteLine("Done.");
            System.Threading.Thread.Sleep(2000);
        }
        static void Main(string[] args)
        {
            string myConnectionStringMDB =
                "Provider=Microsoft.ACE.OLEDB.12.0;" +
                @"Data Source=C:\Users\Gord\Desktop\fromCE.mdb;";
            string myConnectionStringSQL =
                "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;" +
                @"Data Source=C:\__tmp\myData.sdf;";

            using (OleDbConnection conSQL = new OleDbConnection(),
                   conMDB = new OleDbConnection())
            {
                conSQL.ConnectionString = myConnectionStringSQL;
                conSQL.Open();
                conMDB.ConnectionString = myConnectionStringMDB;
                conMDB.Open();
                using (OleDbCommand cmdSQL = new OleDbCommand(),
                       cmdMDB = new OleDbCommand())
                {
                    cmdSQL.CommandType = System.Data.CommandType.Text;
                    cmdSQL.Connection  = conSQL;
                    cmdSQL.CommandText = "SELECT * FROM [Table1]";
                    var daSQL = new System.Data.OleDb.OleDbDataAdapter();
                    daSQL.SelectCommand = cmdSQL;
                    var dtSQL = new System.Data.DataTable();
                    daSQL.Fill(dtSQL);
                    System.Data.DataTable dtMDB = dtSQL.Clone();
                    foreach (System.Data.DataRow drSQL in dtSQL.Rows)
                    {
                        // .ImportRow() would import the row as "Unchanged", so create a new one
                        System.Data.DataRow drMDB = dtMDB.NewRow();
                        drMDB.ItemArray = drSQL.ItemArray;
                        dtMDB.Rows.Add(drMDB);
                    }
                    cmdMDB.CommandType = System.Data.CommandType.Text;
                    cmdMDB.Connection  = conMDB;
                    cmdMDB.CommandText = "SELECT * FROM [Table1]";
                    var daMDB = new System.Data.OleDb.OleDbDataAdapter();
                    daMDB.SelectCommand = cmdMDB;
                    var cbuilderMDB = new OleDbCommandBuilder(daMDB);
                    cbuilderMDB.QuotePrefix = "[";
                    cbuilderMDB.QuoteSuffix = "]";
                    daMDB.Update(dtMDB);
                }
                conSQL.Close();
                conMDB.Close();
            }
            Console.WriteLine("Done.");
            System.Threading.Thread.Sleep(2000);
        }
Beispiel #9
0
        } // End Function GetProxyArray

        public static string[] GetProxyArray(string json)
        {
            string[] filterCountries = new string[] {
                "Switzerland"
                , "Germany"
                , "Netherlands"
                , "Singapore"

                /*
                 * ,"United Kingdom"
                 * ,"United States"
                 * ,"Japan"
                 * ,"Canada"
                 * ,"France"
                 * ,"Italy"
                 * ,"Australia"
                 * ,"Spain"
                 * ,"Ukraine"
                 * ,"Thailand"
                 * ,"Argentina"
                 */
            };

            string allowedCountries = "'" + string.Join("', '", filterCountries) + "'";

            System.Data.DataTable proxyList = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Data.DataTable>(json);
            System.Data.DataRow[] rows      = proxyList.Select("Anonymity <> 'transparent' AND Country IN ( " + allowedCountries + ") ");

            System.Collections.Generic.List <string> ls = new System.Collections.Generic.List <string>();

            System.Data.DataTable proxyList2 = proxyList.Clone();
            foreach (System.Data.DataRow row in rows)
            {
                // proxyList2.ImportRow(row);
                string address = System.Convert.ToString(row["IP Address"]);
                string port    = System.Convert.ToString(row["Port"]);

                ls.Add(address + ":" + port);
            }


            string proxys = "string[] proxyList = new string[]{ \r\n    \"" + string.Join("\"\r\n    ,\"", ls.ToArray()) + "\" \r\n }; ";

            // System.Console.WriteLine(proxys);

            return(ls.ToArray());
        } // End Function GetProxyArray
Beispiel #10
0
        /// <summary>
        /// 获取表里某页的数据
        /// </summary>
        /// <param name="data">表数据</param>
        /// <param name="PageIndex">当前页</param>
        /// <param name="PageSize">分页大小</param>
        /// <param name="AllPage">返回总页数</param>
        /// <returns>返回当页表数据</returns>
        public static System.Data.DataTable GetPage(this System.Data.DataTable data, int PageIndex, int PageSize, out int AllPage)
        {
            AllPage  = data.Rows.Count / PageSize;
            AllPage += data.Rows.Count % PageSize == 0 ? 0 : 1;
            System.Data.DataTable Ntable = data.Clone();
            int startIndex = PageIndex * PageSize;
            int endIndex   = startIndex + PageSize > data.Rows.Count ? data.Rows.Count : startIndex + PageSize;

            if (startIndex < endIndex)
            {
                for (int i = startIndex; i < endIndex; i++)
                {
                    Ntable.ImportRow(data.Rows[i]);
                }
            }
            return(Ntable);
        }
        public void Del()
        {
            if (this.m_dtMedCommonUseDel == null)
            {
                m_dtMedCommonUseDel = m_dtMedCommonUse.Clone();
            }
            int count = this.m_objViewer.m_dgCommonUse.m_arrSelectRows().Length;

            for (int i1 = 0; i1 < this.m_objViewer.m_dgCommonUse.RowCount; i1++)
            {
                if (this.m_objViewer.m_dgCommonUse.m_blnRowIsSelected(i1))
                {
                    m_dtMedCommonUseDel.ImportRow(this.m_objViewer.m_dgCommonUse.m_objGetRow(i1));                                                          m_dtMedCommonUse.Rows[i1].Delete();
                    m_dtMedCommonUse.AcceptChanges();
                    count--;
                }
                if (count <= 0)
                {
                    break;
                }
            }
        }
Beispiel #12
0
        public System.Data.DataSet GetSmtKpDetaltByMasterIdNew(string masterId, string woId, out string Err)
        {
            System.Data.DataTable dtMaterial = new System.Data.DataTable();
            System.Data.DataSet   _ds        = new System.Data.DataSet();
            try
            {
                string         fieldlist         = "STATIONNO,KPNUMBER,KPDESC,KPDISTINCT,REPLACEGROUP,PRIORITYCLASS,LOCTION,RESERVE1,RESERVE";
                int            count             = 0;
                IAdminProvider dp                = (IAdminProvider)DpFactory.Create(typeof(IAdminProvider), DpFactory.ADMIN);
                IDictionary <string, object> mst = new Dictionary <string, object>();
                mst.Add("MASTERID", masterId);
                System.Data.DataTable dt1 = dp.GetData("SFCR.T_SMT_KP_DETALT", fieldlist, mst, out count).Tables[0];
                dtMaterial = dt1.Clone();

                mst = new Dictionary <string, object>();
                mst.Add("WOID", woId);
                mst.Add("MASTERID", masterId);
                System.Data.DataTable dt2 = dp.GetData("SFCR.T_SMT_KP_DETALT_FORWO", fieldlist, mst, out count).Tables[0];

                foreach (System.Data.DataRow dr in dt1.Rows)
                {
                    dtMaterial.Rows.Add(dr["STATIONNO"].ToString(), dr["KPNUMBER"].ToString(), dr["KPDESC"].ToString(), dr["KPDISTINCT"].ToString(), dr["REPLACEGROUP"].ToString(), dr["PRIORITYCLASS"].ToString(), dr["LOCTION"].ToString(), dr["RESERVE1"].ToString(), dr["RESERVE"].ToString());
                }

                foreach (System.Data.DataRow dr in dt2.Rows)
                {
                    dtMaterial.Rows.Add(dr["STATIONNO"].ToString(), dr["KPNUMBER"].ToString(), dr["KPDESC"].ToString(), dr["KPDISTINCT"].ToString(), dr["REPLACEGROUP"].ToString(), dr["PRIORITYCLASS"].ToString(), dr["LOCTION"].ToString(), dr["RESERVE1"].ToString(), dr["RESERVE"].ToString());
                }
                _ds.Tables.Add(dtMaterial);
                Err = "OK";
                return(_ds);
            }
            catch (Exception ex)
            {
                Err = ex.Message;
                return(null);
            }
        }
        private static void UploadBlob(List <FileError> fileErrors, System.Text.StringBuilder ErrorRecord, System.Text.StringBuilder AcceptedRecord, string blobName, string PayerID)
        {
            string FileName = System.IO.Path.GetFileName(blobName);
            CloudStorageAccount mycloudStorageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("StorageConnection"));
            CloudBlobClient     blobClient            = mycloudStorageAccount.CreateCloudBlobClient();
            CloudBlobContainer  container             = blobClient.GetContainerReference("claimshark");

            container.CreateIfNotExistsAsync().Wait();
            if (ErrorRecord.ToString().Length > 0)
            {
                var blob = container.GetBlockBlobReference(PayerID + "/ErrorBlob/" + FileName);
                using (Stream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(ErrorRecord.ToString())))
                {
                    blob.UploadFromStreamAsync(stream).Wait();
                }
                blob = container.GetBlockBlobReference(PayerID + "/ErrorBlob/ErrorDetails_" + FileName);
                using (Stream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(fileErrors))))
                {
                    blob.UploadFromStreamAsync(stream).Wait();
                }
            }
            if (AcceptedRecord.ToString().Length > 0)
            {
                System.Data.DataTable dataTableClean = dtPayerDataTable.Clone();
                var Accepted = dtPayerDataTable.Select("IsValid=1");
                foreach (var dr in Accepted)
                {
                    dataTableClean.ImportRow(dr);
                }
                var blob = container.GetBlockBlobReference(PayerID + "/Payer/InBound/" + FileName);
                using (Stream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(dataTableClean))))
                {
                    blob.UploadFromStreamAsync(stream).Wait();
                }
            }
        }
        public void m_mthFind()
        {
            if (this.m_objViewer.m_cmbCondition.SelectedIndex == -1 || this.m_objViewer.m_txtMedName.Text == string.Empty)
            {
                return;
            }
            System.Data.DataTable dtFind = dt.Clone();
            string strColumn             = "";
            string strFiled = "";

            if (this.m_objViewer.m_txtMedName.Text != "")
            {
                switch (this.m_objViewer.m_cmbCondition.SelectedIndex)
                {
                case 0:
                    strColumn = "ITEMCODE_VCHR";
                    strFiled  = this.m_objViewer.m_txtMedName.Text;
                    break;

                case 1:
                    strColumn = "ITEMNAME_VCHR";
                    strFiled  = this.m_objViewer.m_txtMedName.Text;
                    break;

                case 2:
                    strColumn = "ITEMPYCODE_CHR";
                    strFiled  = this.m_objViewer.m_txtMedName.Text.ToUpper();
                    break;

                case 3:
                    strColumn = "ITEMWBCODE_CHR";
                    strFiled  = this.m_objViewer.m_txtMedName.Text.ToUpper();
                    break;

                case 4:
                    strColumn = "ITEMENGNAME_VCHR";
                    strFiled  = this.m_objViewer.m_txtMedName.Text;
                    break;
                }
            }
            System.Data.DataRow[] objRows = dt.Select(strColumn + " like '" + strFiled + "%'");
            if (objRows.Length > 0)
            {
                for (int i1 = 0; i1 < objRows.Length; i1++)
                {
                    m_mthAddRowForTable(objRows[i1], ref dtFind);
                }
            }
            this.m_objViewer.m_dgMedBse.m_mthSetDataTable(dtFind);
            //this.m_objViewer.m_dgMedBse.BeginUpdate();
            //for(int i1=0;i1<dt.Rows.Count;i1++)
            //{

            //    if(dt.Rows[i1]["NOQTYFLAG_INT"].ToString()=="1")
            //    {
            //        for(int f2=0;f2<3;f2++)
            //        {
            //            this.m_objViewer.m_dgMedBse.m_mthFormatCell(i1,f2,m_objViewer.m_dgMedBse.Font,System.Drawing.Color.White,System.Drawing.Color.Red);
            //        }

            //    }
            //}
            //this.m_objViewer.m_dgMedBse.EndUpdate();
        }
Beispiel #15
0
        private void InitialFormData()
        {
            string sql = null;

            System.Data.DataTable   dt    = null;
            System.Data.DataTable   dtcpy = null;
            System.Data.DataTable[] dtV   = new System.Data.DataTable[11];
            System.Data.DataRow     dr    = null;
            sql   = "select ltrim(str(amount,20,2)) as pa,pa_code+' '+ltrim(str(amount,20,2))+' '+remark as pa_desc from finance_payment_detail ";
            sql  += " where ref_code in (" + this._pacode + ")";
            sql  += " order by amount";
            dt    = TJSystem.Public.PublicStatic.db.GetDataTable(sql);
            dr    = dt.NewRow();
            dr[0] = "0";
            dr[1] = "";
            dt.Rows.InsertAt(dr, 0);
            dtcpy = dt.Copy();

            for (int i = 0; i < 11; i++)
            {
                dtV[i] = dtcpy.Copy();
            }
            this.comboBox1.DataSource    = dtV[0].DefaultView;
            this.comboBox1.ValueMember   = "pa";
            this.comboBox1.DisplayMember = "pa_desc";

            this.comboBox2.DataSource    = dtV[1].DefaultView;
            this.comboBox2.ValueMember   = "pa";
            this.comboBox2.DisplayMember = "pa_desc";

            this.comboBox3.DataSource    = dtV[2].DefaultView;
            this.comboBox3.ValueMember   = "pa";
            this.comboBox3.DisplayMember = "pa_desc";

            sql  = "select";
            sql += " ltrim(str(sum(a.amount*a.exchange),20,2)) as pa,' RMB'+' '+a.term as pa_desc ";
            sql += " from finance_payawb a";
            sql += " where term in (" + this._pacode + ")";
            sql += " group by ' RMB'+' '+a.term";
//			sql = "select ltrim(str(amount,20,2)) as pa,pa_code+' '+ltrim(str(amount,20,2))+' '+pa_date as pa_desc from finance_payawb ";
            sql  += " order by pa desc";
            dt    = TJSystem.Public.PublicStatic.db.GetDataTable(sql);
            dtcpy = dt.Clone();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr    = dtcpy.NewRow();
                dr[0] = dt.Rows[i]["pa"].ToString();
                dr[1] = dt.Rows[i]["pa"].ToString() + " " + dt.Rows[i]["pa_desc"].ToString();
                dtcpy.Rows.InsertAt(dr, 0);
            }
            dr    = dtcpy.NewRow();
            dr[0] = "0";
            dr[1] = "";
            dtcpy.Rows.InsertAt(dr, 0);
//			dtcpy = dt.Copy();
            this.comboBox4.DataSource    = dtcpy.DefaultView;
            this.comboBox4.ValueMember   = "pa";
            this.comboBox4.DisplayMember = "pa_desc";

            dtV[6] = dtcpy.Copy();

            this.comboBox5.DataSource    = dtV[4].DefaultView;
            this.comboBox5.ValueMember   = "pa";
            this.comboBox5.DisplayMember = "pa_desc";

            this.comboBox6.DataSource    = dtV[5].DefaultView;
            this.comboBox6.ValueMember   = "pa";
            this.comboBox6.DisplayMember = "pa_desc";

            this.comboBox7.DataSource    = dtV[6].DefaultView;
            this.comboBox7.ValueMember   = "pa";
            this.comboBox7.DisplayMember = "pa_desc";

            this.comboBox8.DataSource    = dtV[7].DefaultView;
            this.comboBox8.ValueMember   = "pa";
            this.comboBox8.DisplayMember = "pa_desc";

            this.comboBox9.DataSource    = dtV[8].DefaultView;
            this.comboBox9.ValueMember   = "pa";
            this.comboBox9.DisplayMember = "pa_desc";

            this.comboBox10.DataSource    = dtV[9].DefaultView;
            this.comboBox10.ValueMember   = "pa";
            this.comboBox10.DisplayMember = "pa_desc";

            this.comboBox11.DataSource    = dtV[10].DefaultView;
            this.comboBox11.ValueMember   = "pa";
            this.comboBox11.DisplayMember = "pa_desc";

            this.textBox7.Text  = this.cfg.gnyzf.ToString("f2");
            this.textBox12.Text = this.cfg.myfl.ToString("f2");
        }
Beispiel #16
0
        /// <summary>
        /// Count all tables records.
        /// </summary>
        /// <param name="p_tables">List of table names.</param>
        /// <param name="p_filters">List of table filters.</param>
        public System.Data.DataTable CountTablesRecords(System.Collections.Generic.List <string> p_tables, System.Collections.Generic.List <string> p_filters)
        {
            System.Data.DataTable v_count_total_table = new System.Data.DataTable();

            int v_timeout = v_connection.v_timeout;

            v_connection.SetTimeout(0);

            string v_sql = "";

            bool v_first = true;

            int v_block_counter = 0;

            for (int j = 0; j < p_tables.Count; j++)
            {
                if (!v_first)
                {
                    v_sql += " union all ";
                }

                v_first = false;

                v_block_counter++;


                string v_table_name = "";

                if (v_has_schema)
                {
                    v_table_name = v_schema + "." + p_tables[j];
                }
                else
                {
                    v_table_name = p_tables[j];
                }


                v_sql += "select count(*) as total, " + v_trim_function + "('" + p_tables[j] + "') as table_name from " + v_table_name + " " + p_filters[j] + " ";



                if (v_block_counter >= 50 || (j == p_tables.Count - 1))
                {
                    if (v_count_total_table == null)
                    {
                        v_count_total_table = v_connection.Query(v_sql, "t1");
                    }
                    else
                    {
                        v_count_total_table.Merge(v_connection.Query(v_sql, "t1"));
                    }
                    v_first         = true;
                    v_block_counter = 0;

                    v_sql = "";
                }
            }

            System.Data.DataTable dt2 = v_count_total_table.Clone();
            dt2.Columns["total"].DataType = Type.GetType("System.Int32");

            foreach (System.Data.DataRow dr in v_count_total_table.Rows)
            {
                dt2.ImportRow(dr);
            }

            dt2.AcceptChanges();
            System.Data.DataView dv = dt2.DefaultView;
            dv.Sort = "total DESC";

            v_count_total_table = dv.ToTable();

            v_connection.SetTimeout(v_timeout);

            return(v_count_total_table);
        }
Beispiel #17
0
        public void AgendaRuptura(ProgressBar pBar, DateTime data)
        {
            System.Data.DataTable lista;
            DateTime hoje = data;//DateTime.Now.Date;

            System.Data.DataTable resultado = rRelatorio.AgendaRuptura();
            lista = resultado.Clone();
            lista.Clear();
            pBar.Maximum = resultado.Rows.Count;
            pBar.Minimum = 0;
            for (int i = 0; i < resultado.Rows.Count; i++)
            {
                DateTime compara  = Convert.ToDateTime(resultado.Rows[i][1].ToString());
                DateTime comparaA = new DateTime();
                DateTime comparaB = new DateTime();
                DateTime comparaC = new DateTime();
                if (resultado.Rows[i][6].ToString() != "")
                {
                    comparaA = compara.AddDays(Convert.ToInt32(resultado.Rows[i][6].ToString()));
                }
                if (resultado.Rows[i][7].ToString() != "")
                {
                    comparaB = compara.AddDays(Convert.ToInt32(resultado.Rows[i][7].ToString()));
                }
                if (resultado.Rows[i][8].ToString() != "")
                {
                    comparaC = compara.AddDays(Convert.ToInt32(resultado.Rows[i][8].ToString()));
                }
                if ((comparaA == hoje && resultado.Rows[i][3].ToString() != "") || (comparaB == hoje && resultado.Rows[i][5].ToString() != "") || (comparaC == hoje && resultado.Rows[i][7].ToString() != ""))
                {
                    lista.ImportRow(resultado.Rows[i]);
                }
            }
            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            string    workbookPath   = System.Windows.Forms.Application.StartupPath.ToString() + @"\Arquivos\AgendaRuptura.xlsx";
            Workbook  excelWorkbook  = excelApp.Workbooks.Open(workbookPath, 0, false, 5, "", "", false, XlPlatform.xlWindows, "", true, false, 0, true, false, false);
            Sheets    excelSheets    = excelWorkbook.Worksheets;
            string    currentSheet   = "Form";
            Worksheet excelWorksheet = (Worksheet)excelSheets.get_Item(currentSheet);
            Range     excelCell;

            excelApp.DisplayAlerts  = false;
            excelApp.ScreenUpdating = false;
            for (int i = 0; i < lista.Rows.Count; i++)
            {
                string teste = Convert.ToString(i * 2 + 11);
                excelCell        = (Range)excelWorksheet.get_Range("B" + teste);
                excelCell.Value2 = lista.Rows[i][0].ToString();
                if (Convert.ToDateTime(lista.Rows[i][1].ToString()).AddDays(Convert.ToInt32(lista.Rows[i][6].ToString())) == DateTime.Now.Date)
                {
                    excelCell        = (Range)excelWorksheet.get_Range("C" + i * 2 + 11);
                    excelCell.Value2 = lista.Rows[i][6].ToString();
                }
                else if (Convert.ToDateTime(lista.Rows[i][1].ToString()).AddDays(Convert.ToInt32(lista.Rows[i][7].ToString())) == DateTime.Now.Date)
                {
                    excelCell        = (Range)excelWorksheet.get_Range("C" + i * 2 + 11);
                    excelCell.Value2 = lista.Rows[i][7].ToString();
                }
                else if (Convert.ToDateTime(lista.Rows[i][1].ToString()).AddDays(Convert.ToInt32(lista.Rows[i][8].ToString())) == DateTime.Now.Date)
                {
                    excelCell        = (Range)excelWorksheet.get_Range("C" + i * 2 + 11);
                    excelCell.Value2 = lista.Rows[i][8].ToString();
                }
                excelCell        = (Range)excelWorksheet.get_Range("D" + i * 2 + 11);
                excelCell.Value2 = lista.Rows[i][2].ToString();
                System.Data.DataTable obra = rObra.Buscar(lista.Rows[i][3].ToString(), "cIDObra");
                System.Data.DataTable eixo = rEixo.buscar(lista.Rows[i][4].ToString(), obra.Rows[0][0].ToString(), "cIDEixo");
                System.Data.DataTable peca = rPeca.buscar(lista.Rows[i][5].ToString(), eixo.Rows[0][0].ToString(), obra.Rows[0][0].ToString(), "cIDPeca");
                excelCell        = (Range)excelWorksheet.get_Range("E" + i * 2 + 11);
                excelCell.Value2 = obra.Rows[0][1].ToString() + " / " + eixo.Rows[0][2].ToString() + " / " + peca.Rows[0][3].ToString();
            }
            excelWorksheet.PrintOutEx(1, 1, Properties.Settings.Default.NumberCopies, Properties.Settings.Default.PreviewPrint, Properties.Settings.Default.Printer, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            excelWorkbook.Close(false, Type.Missing, Type.Missing);
            excelApp.Quit();
        }
Beispiel #18
0
        private Hubble.Framework.Data.DataTable GroupByFromDatabase()
        {
            string whereSql;

            if (_ExpressionTree == null)
            {
                whereSql = "";
            }
            else
            {
                whereSql = "where " + _ExpressionTree.SqlText;
            }

            StringBuilder sb = new StringBuilder();

            string fields = "";
            int    i      = 0;

            foreach (Field field in _GroupByFields)
            {
                if (i++ == 0)
                {
                    fields += field.Name;
                }
                else
                {
                    fields += "," + field.Name;
                }
            }

            string sql = string.Format("select {0} , count(*) as Count from {1} {2} group by {0} order by count desc",
                                       fields, _DBProvider.Table.DBTableName, whereSql);

            System.Data.DataTable src   = _DBProvider.DBAdapter.QuerySql(sql).Tables[0];
            System.Data.DataTable table = src.Clone();

            table.MinimumCapacity = src.Rows.Count;
            int top = _Top;

            if (top < 0)
            {
                top = int.MaxValue;
            }

            i = 0;
            while (top > 0 && i < src.Rows.Count)
            {
                System.Data.DataRow row = table.NewRow();

                for (int j = 0; j < table.Columns.Count; j++)
                {
                    row[j] = src.Rows[i][j];
                }

                table.Rows.Add(row);

                i++;
                top--;
            }

            table.TableName = "GroupByCount_" + _GroupByFieldsString;


            return(new Hubble.Framework.Data.DataTable(table));
        }
Beispiel #19
0
 /// <summary>
 /// 获取叶结点
 /// </summary>
 /// <param name="table">数据源</param>
 /// <param name="TopID">顶级ID值</param>
 /// <param name="IDColl">ID列名称</param>
 /// <param name="PIDColl">父级ID列名称</param>
 /// <returns>反回列结点值</returns>
 public static System.Data.DataTable GetLastNode(this System.Data.DataTable table, int TopID, string IDColl, string PIDColl)
 {
     System.Data.DataTable reTable = table.Clone();
     FindLastNode(reTable, table, TopID, IDColl, PIDColl);
     return(reTable);
 }
Beispiel #20
0
        public void Resistencia(DateTime data)
        {
            System.Data.DataTable lista;
            DateTime hoje = data;//DateTime.Now.Date.AddDays(-4);

            System.Data.DataTable resultado = rRelatorio.RelatorioRuptura();
            lista = resultado.Clone();
            lista.Clear();
            for (int i = 0; i < resultado.Rows.Count; i++)
            {
                DateTime compara  = Convert.ToDateTime(resultado.Rows[i][2].ToString());
                DateTime comparaA = new DateTime();
                DateTime comparaB = new DateTime();
                DateTime comparaC = new DateTime();
                if (resultado.Rows[i][6].ToString() != "")
                {
                    comparaA = compara.AddDays(Convert.ToInt32(resultado.Rows[i][10].ToString()));
                }
                if (resultado.Rows[i][7].ToString() != "")
                {
                    comparaB = compara.AddDays(Convert.ToInt32(resultado.Rows[i][11].ToString()));
                }
                if (resultado.Rows[i][8].ToString() != "")
                {
                    comparaC = compara.AddDays(Convert.ToInt32(resultado.Rows[i][12].ToString()));
                }
                if (comparaA == hoje || comparaB == hoje || comparaC == hoje)
                {
                    lista.ImportRow(resultado.Rows[i]);
                }
            }

            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            string    workbookPath   = System.Windows.Forms.Application.StartupPath.ToString() + @"\Arquivos\RelatorioResisencia.xlsx";
            Workbook  excelWorkbook  = excelApp.Workbooks.Open(workbookPath, 0, false, 5, "", "", false, XlPlatform.xlWindows, "", true, false, 0, true, false, false);
            Sheets    excelSheets    = excelWorkbook.Worksheets;
            string    currentSheet   = "FormRes";
            Worksheet excelWorksheet = (Worksheet)excelSheets.get_Item(currentSheet);
            Range     excelCell;

            excelApp.DisplayAlerts  = false;
            excelApp.ScreenUpdating = false;
            for (int i = 0; i < lista.Rows.Count; i++)
            {
                excelCell        = (Range)excelWorksheet.get_Range("B" + i + 10); //Serie
                excelCell.Value2 = lista.Rows[i][0].ToString();
                excelCell        = (Range)excelWorksheet.get_Range("C" + i + 10); //Lote
                excelCell.Value2 = lista.Rows[i][1].ToString();
                if (Convert.ToDateTime(lista.Rows[i][2].ToString()).AddDays(Convert.ToInt32(lista.Rows[i][10].ToString())) == DateTime.Now.Date)
                {
                    excelCell        = (Range)excelWorksheet.get_Range("D" + i + 10); //Idade
                    excelCell.Value2 = lista.Rows[i][10].ToString();
                    excelCell        = (Range)excelWorksheet.get_Range("I" + i + 10); //Resistencia 1
                    excelCell.Value2 = lista.Rows[i][3].ToString();
                    excelCell        = (Range)excelWorksheet.get_Range("J" + i + 10); //Resistencia 2
                    excelCell.Value2 = lista.Rows[i][4].ToString();
                    if (Convert.ToInt32(lista.Rows[i][3].ToString()) < Convert.ToInt32(lista.Rows[i][4].ToString()))
                    {
                        excelCell        = (Range)excelWorksheet.get_Range("K" + i + 10);//fi
                        excelCell.Value2 = lista.Rows[i][4].ToString();
                    }
                    else
                    {
                        excelCell        = (Range)excelWorksheet.get_Range("K" + i + 10);//fi
                        excelCell.Value2 = lista.Rows[i][3].ToString();
                    }
                }
                else if (Convert.ToDateTime(lista.Rows[i][2].ToString()).AddDays(Convert.ToInt32(lista.Rows[i][11].ToString())) == DateTime.Now.Date)
                {
                    excelCell        = (Range)excelWorksheet.get_Range("D" + i + 10); //Idade
                    excelCell.Value2 = lista.Rows[i][11].ToString();
                    excelCell        = (Range)excelWorksheet.get_Range("I" + i + 10); //Resistencia 1
                    excelCell.Value2 = lista.Rows[i][5].ToString();
                    excelCell        = (Range)excelWorksheet.get_Range("J" + i + 10); //Resistencia 2
                    excelCell.Value2 = lista.Rows[i][6].ToString();
                    if (Convert.ToInt32(lista.Rows[i][5].ToString()) < Convert.ToInt32(lista.Rows[i][6].ToString()))
                    {
                        excelCell        = (Range)excelWorksheet.get_Range("K" + i + 10);//fi
                        excelCell.Value2 = lista.Rows[i][6].ToString();
                    }
                    else
                    {
                        excelCell        = (Range)excelWorksheet.get_Range("K" + i + 10);//fi
                        excelCell.Value2 = lista.Rows[i][5].ToString();
                    }
                }
                else if (Convert.ToDateTime(lista.Rows[i][2].ToString()).AddDays(Convert.ToInt32(lista.Rows[i][12].ToString())) == DateTime.Now.Date)
                {
                    excelCell        = (Range)excelWorksheet.get_Range("D" + i + 10); //Idade
                    excelCell.Value2 = lista.Rows[i][12].ToString();
                    excelCell        = (Range)excelWorksheet.get_Range("I" + i + 10); //Resistencia 1
                    excelCell.Value2 = lista.Rows[i][7].ToString();
                    excelCell        = (Range)excelWorksheet.get_Range("J" + i + 10); //Resistencia 2
                    excelCell.Value2 = lista.Rows[i][8].ToString();
                    if (Convert.ToInt32(lista.Rows[i][7].ToString()) < Convert.ToInt32(lista.Rows[i][8].ToString()))
                    {
                        excelCell        = (Range)excelWorksheet.get_Range("K" + i + 10);//fi
                        excelCell.Value2 = lista.Rows[i][8].ToString();
                    }
                    else
                    {
                        excelCell        = (Range)excelWorksheet.get_Range("K" + i + 10);//fi
                        excelCell.Value2 = lista.Rows[i][7].ToString();
                    }
                }
                excelCell        = (Range)excelWorksheet.get_Range("E" + i + 10);
                excelCell.Value2 = lista.Rows[i][9].ToString();
                excelCell        = (Range)excelWorksheet.get_Range("F" + i * 2 + 11);
                excelCell.Value2 = lista.Rows[i][13].ToString() + " / " + lista.Rows[i][14].ToString() + " / " + lista.Rows[i][15].ToString();
            }
            //excelApp.Visible = true;
            excelWorksheet.PrintOutEx(1, 1, Properties.Settings.Default.NumberCopies, Properties.Settings.Default.PreviewPrint, Properties.Settings.Default.Printer, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            excelWorkbook.Close(false, Type.Missing, Type.Missing);
            excelApp.Quit();
        }