Exemplo n.º 1
0
        private void cmbTableUn_SelectedIndexChanged(object sender, EventArgs e)
        {
            grdData.Rows.Clear();
            grdData.Columns.Clear();

            mycon = new ADODB.Connection();
            mycon.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " + clsDataStorage.db.Name);
            recordSet = new ADODB.Recordset();
            recordSet.Open("SELECT * FROM " + cmbTableUn.Text, mycon, CursorTypeEnum.adOpenStatic);

            //clsDataStorage.db.OpenTable(cmbTableUn.Text);

            foreach (ADODB.Field field in recordSet.Fields)
            {
                grdData.Columns.Add("clm" + field.Name, field.Name);
            }

            while (!recordSet.EOF)
            {
                grdData.Rows.Add();

                for (int i = 0; i < recordSet.Fields.Count; i++)
                {
                    grdData.Rows[r].Cells[i].Value = recordSet.Fields[i].Value;
                }
                r++;
                recordSet.MoveNext();
            }
            r = 0;
            recordSet.Close();
        }
Exemplo n.º 2
0
        public string Gf_GroupSet(string shift, string setDate)
        {
            if (GeneralCommon.M_CN1.State == 0)
            {
                if (!GeneralCommon.GF_DbConnect())
                {
                    return("");
                }
            }

            string sQuery;
            string group = "0";

            sQuery = "SELECT Gf_Groupset('C3'," + shift + ",SUBSTR('" + setDate + "',1,8)) FROM DUAL";

            ADODB.Recordset AdoRs = new ADODB.Recordset();
            try
            {
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                if (!AdoRs.BOF && !AdoRs.EOF)
                {
                    //RltValue = true;
                    while (!AdoRs.EOF)
                    {
                        if (AdoRs.Fields[0].Value.ToString() == "")
                        {
                            group = "";
                        }
                        else
                        {
                            group = AdoRs.Fields[0].Value.ToString();
                        }
                        AdoRs.MoveNext();
                    }
                }

                GeneralCommon.M_CN1.Close();

                AdoRs = null;

                return(group);
            }
            catch (Exception ex)
            {
                if (GeneralCommon.M_CN1.State != 0)
                {
                    GeneralCommon.M_CN1.Close();
                }
                AdoRs = null;
                return("");
            }
        }
Exemplo n.º 3
0
        private double Cal_Plate_Wgt(string sMode, string sEndUseCd, string sStlgrd, double dThk, double dWid, double dLen)
        {
            double Plate_Wgt = 0;

            sQuery = "SELECT  Gf_Cal_Plate_Wgt('" + sMode + "'";
            sQuery = sQuery + "             ,'" + sEndUseCd + "'";
            sQuery = sQuery + "             ,'" + sStlgrd + "'";
            sQuery = sQuery + "             ," + dThk;
            sQuery = sQuery + "             ," + dWid;
            sQuery = sQuery + "             ," + dLen;
            sQuery = sQuery + "             ,0 )";
            sQuery = sQuery + "       FROM  DUAL ";

            if (GeneralCommon.M_CN1.State == 0)
            {
                if (!GeneralCommon.GF_DbConnect())
                {
                    return(Plate_Wgt);
                }
            }


            ADODB.Recordset AdoRs = new ADODB.Recordset();
            try
            {
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                if (!AdoRs.BOF && !AdoRs.EOF)
                {
                    //RltValue = true;
                    while (!AdoRs.EOF)
                    {
                        Plate_Wgt = Convert.ToDouble(AdoRs.Fields[0].Value);
                        AdoRs.MoveNext();
                    }
                }

                //判断是不是需要关闭连接对象,有时候该方法是在查询过程中调用,关闭对象会导致框架查询报错 韩超

                GeneralCommon.M_CN1.Close();

                AdoRs = null;

                return(Plate_Wgt);
            }
            catch (Exception ex)
            {
                // if (GeneralCommon.M_CN1.State != 0) GeneralCommon.M_CN1.Close();
                AdoRs = null;
                return(0);
            }
        }
Exemplo n.º 4
0
        private bool IsColumnReadOnly(string name, string column)
        {
            if (radioSql.Checked)
            {
                int  tableid = Gateway.Default.SelectScalar <int>("select id from sysobjects where [name] = @name", new object[] { name });
                byte status  = Gateway.Default.SelectScalar <byte>("select status from syscolumns where [name] = @name and id = @id", new object[] { column, tableid });
                return(status == 128);
            }
            else if (radioOracle.Checked)
            {
                return(false);
            }
            else if (radioMySql.Checked)
            {
                System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("(^.*database=)([^;]+)(;.*)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                string dbName = r.Replace(txtConnStr.Text, "$2").ToLower();

                DataSet ds = Gateway.Default.SelectDataSet("select EXTRA from COLUMNS where TABLE_SCHEMA = '" + dbName + "' and COLUMN_NAME = '" + column + "' and TABLE_NAME = ?TABLE_NAME", new object[] { name });
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i][0].ToString() == "auto_increment")
                    {
                        return(true);
                    }
                }

                return(false);
            }
            else
            {
                ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
                conn.Provider = "Microsoft.Jet.OLEDB.4.0";
                string connStr = txtConnStr.Text;
                conn.Open(connStr.Substring(connStr.ToLower().IndexOf("data source") + "data source".Length).Trim('=', ' '), null, null, 0);

                ADODB.Recordset rs = conn.GetType().InvokeMember("OpenSchema", BindingFlags.InvokeMethod, null, conn, new object[] { ADODB.SchemaEnum.adSchemaColumns }) as ADODB.Recordset;
                rs.Filter = "TABLE_NAME='" + name + "'";

                while (!rs.EOF)
                {
                    if ((rs.Fields["COLUMN_NAME"].Value as string) == column && ((int)rs.Fields["DATA_TYPE"].Value) == 3 && Convert.ToByte(rs.Fields["COLUMN_FLAGS"].Value) == 90)
                    {
                        return(true);
                    }

                    rs.MoveNext();
                }
            }

            return(false);
        }
Exemplo n.º 5
0
 protected override bool InternalNext()
 {
     if (_bOF)
     {
         _bOF = false;
     }
     else
     if (!_recordset.EOF)
     {
         _recordset.MoveNext();
     }
     ClearValues();
     return(!_recordset.EOF);
 }
Exemplo n.º 6
0
        private void ProcessSumAndUpdateRs()
        {
            short     cNo               = 0;
            string    field             = string.Empty;
            int       attributeValueSum = 0;
            Recordset bankAttributesRs  = null;

            try
            {
                //Calculate attribute value sum
                IGTComponent    component    = Components[ComponentName];
                ADODB.Recordset kvaResultsRs = component.Recordset;
                if (kvaResultsRs.RecordCount > 0)
                {
                    int deletetedValue = string.IsNullOrEmpty(Convert.ToString(kvaResultsRs.Fields["KVA_Q"].Value)) ? 0 : Convert.ToInt32(kvaResultsRs.Fields["KVA_Q"].Value);
                    kvaResultsRs.MoveFirst();
                    while (!kvaResultsRs.EOF)
                    {
                        attributeValueSum = attributeValueSum + (string.IsNullOrEmpty(Convert.ToString(kvaResultsRs.Fields["KVA_Q"].Value)) ? 0 : Convert.ToInt32(kvaResultsRs.Fields["KVA_Q"].Value));
                        kvaResultsRs.MoveNext();
                    }
                    if (m_isDelete)
                    {
                        attributeValueSum = attributeValueSum - deletetedValue;
                    }
                }

                //Get the attribute to be updated and update the attribute sum to this attribute

                string          sqlString = string.Format("select g3e_field FIELD, g3e_cno CNO from G3E_ATTRIBUTEINFO_OPTABLE where g3e_ano = {0} ", Convert.ToInt32(m_Arguments.GetArgument(0)));
                ADODB.Recordset results   = GetRecordSet(sqlString);

                if (results.RecordCount > 0)
                {
                    results.MoveFirst();
                    cNo   = Convert.ToInt16(results.Fields["CNO"].Value);
                    field = Convert.ToString(results.Fields["FIELD"].Value);
                }

                bankAttributesRs = Components.GetComponent(cNo).Recordset;
                bankAttributesRs.MoveFirst();
                bankAttributesRs.Fields[field].Value = attributeValueSum;
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 7
0
 // Need to reset the recordset position before doing any updates.
 // The position changes from the starting postion due to looping
 // through the recordset and possibly through other interfaces
 // that get called.
 private void ResetRecordPosition(ref ADODB.Recordset componentRS)
 {
     // Reset the recordset position
     if (m_RecordPosition != (int)componentRS.AbsolutePosition)
     {
         componentRS.MoveFirst();
         while (!componentRS.EOF)
         {
             if (m_RecordPosition == (int)componentRS.AbsolutePosition)
             {
                 break;
             }
             componentRS.MoveNext();
         }
     }
 }
Exemplo n.º 8
0
        // Loop through the current Premise records on the active Service Point feature
        // and validate that the entered ESI Location on the current Premise record
        // does not exist on another Premise record for the active Service Point.
        private bool ValidateDuplicateOnExistingFID(string esiLocation, ADODB.Recordset componentRS)
        {
            bool returnValue = true;

            try
            {
                componentRS.MoveFirst();

                int    currentRecordPosition = 0;
                string currentESILocation    = "";

                while (!componentRS.EOF)
                {
                    currentRecordPosition = (int)componentRS.AbsolutePosition;

                    if (currentRecordPosition != m_RecordPosition)
                    {
                        if (!Convert.IsDBNull(componentRS.Fields[FIELD_PREMISE_ESI_LOCATION].Value))
                        {
                            currentESILocation = componentRS.Fields[FIELD_PREMISE_ESI_LOCATION].Value.ToString();

                            if (esiLocation == currentESILocation)
                            {
                                if (m_InteractiveMode)
                                {
                                    MessageBox.Show(ERROR_DUPLICATE_ESILOCATION_SRVCPT, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                returnValue = false;
                                break;
                            }
                        }
                    }
                    componentRS.MoveNext();
                }
            }
            catch (Exception ex)
            {
                if (m_InteractiveMode)
                {
                    MessageBox.Show("Error in fiESILocationUpdate:ValidateDuplicateOnExistingFID - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                returnValue = false;
            }

            return(returnValue);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Method to update the Structure Id of associated work points for a structure
        /// </summary>
        /// <param name="fno"></param>
        /// <param name="fid"></param>
        /// <param name="newStructureId"></param>
        private void UpdateAssociatedWorkPointsStructureId(short fno, int fid, string newStructureId)
        {
            List <int> workPointFidList = null;

            try
            {
                int             recordsAffected = 0;
                ADODB.Recordset rs = DataContext.Execute("select g3e_fid WPFID from workpoint_cu_n where assoc_fid = " + fid + " and assoc_fno =" + fno, out recordsAffected, (int)ADODB.CommandTypeEnum.adCmdText, new int[0]);
                if (rs != null && rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    workPointFidList = new List <int>();
                    while (!rs.EOF)
                    {
                        workPointFidList.Add(Convert.ToInt32(rs.Fields["WPFID"].Value));
                        rs.MoveNext();
                    }
                }

                if (workPointFidList != null)
                {
                    foreach (int wpFid in workPointFidList)
                    {
                        IGTKeyObject workPointFeature = m_DataContext.OpenFeature(191, wpFid);
                        if (workPointFeature != null)
                        {
                            Recordset workPointFeatureRs = workPointFeature.Components.GetComponent(19101).Recordset;
                            if (workPointFeatureRs != null && workPointFeatureRs.RecordCount > 0)
                            {
                                workPointFeatureRs.MoveFirst();
                                workPointFeatureRs.Fields["STRUCTURE_ID"].Value = newStructureId;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 10
0
        public string GetPreferredCuFilterString(ADODB.Recordset p_PreferredCuRecords)
        {
            List <string> sPreferredCuList = new List <string>();
            string        sReturnFilter    = string.Empty;

            if (p_PreferredCuRecords != null)
            {
                if (p_PreferredCuRecords.RecordCount > 0)
                {
                    p_PreferredCuRecords.MoveFirst();
                    while (p_PreferredCuRecords.EOF == false)
                    {
                        sPreferredCuList.Add("'" + Convert.ToString(p_PreferredCuRecords.Fields["CU_CODE"].Value) + "'");
                        p_PreferredCuRecords.MoveNext();
                    }
                    sReturnFilter = string.Join(",", sPreferredCuList.ToArray());
                }
            }

            return(sReturnFilter);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Copies the contents of an ADO Recordset object onto a worksheet, beginning
        /// at the upper-left corner of the specified range.
        /// </summary>
        public void CopyFromRecordset(ADODB.Recordset recordset)
        {
            // Copying from recordset activates the worksheet, if it wasn't already active.
            _worksheet.Activate();

            // Loop through all the records in the set.
            for (int recordNum = 0; recordNum < recordset.RecordCount; recordNum++)
            {
                // Write all the fields in the record.
                for (int fieldNum = 0; fieldNum < recordset.Fields.Count; fieldNum++)
                {
                    writeRecordsetFieldToCell(
                        recordset.Fields[fieldNum],
                        _minRowIndex + recordNum,
                        _minColIndex + fieldNum
                        );
                }

                recordset.MoveNext();
            }
        }
Exemplo n.º 12
0
        private void UpdateADODBRecordset_from_ADODataTable(DataTable inTable, ref ADODB.Recordset adoRs)
        {
            ADODB.Fields adoFields = adoRs.Fields;
            System.Data.DataColumnCollection inColumns = inTable.Columns;
            //Delete
            if (adoRs.RecordCount > 0)
            {
                adoRs.MoveFirst();
            }
            while (!adoRs.EOF)
            {
                adoRs.Delete();
                adoRs.MoveNext();
            }
            //Add
            foreach (DataRow dr in inTable.Rows)
            {
                // Proceso las que no estan borradas
                if (dr.RowState != DataRowState.Deleted)
                {
                    adoRs.AddNew(System.Reflection.Missing.Value,
                                 System.Reflection.Missing.Value);

                    for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
                    {
                        ADODB.Field field = adoFields[columnIndex];
                        try
                        {
                            adoFields[columnIndex].Value = dr[columnIndex];
                        }
                        catch (Exception ex)
                        {
                            string message = string.Format("Error al actualizar la columna {0}.{1}: {2}", inTable.TableName, field.Name, ex.Message);
                            throw new XTangoException(message);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void lvSummaryResults_DoubleClick(object sender, EventArgs e)
        {
            lvDetailedResults.Items.Clear();

            //SS:01/03/2018:2018-R1:ABSEXCH-19796: When Running the ExchDVT.exe, SQL Admin Passwords are visible in dump file.
            ADODB.Connection conn = new ADODB.Connection();
            ADODB.Command    cmd  = new ADODB.Command();
            cmd.CommandText = "SELECT [IntegrityErrorMessage] " +
                              ", [SchemaName] " +
                              ", [TableName] " +
                              ", [PositionID] " +
                              "FROM [common].[SQLDataValidation] " +
                              "WHERE IntegrityErrorCode = '" + lvSummaryResults.SelectedItems[0].Text + "' " +
                              "AND SchemaName = '" + lvSummaryResults.SelectedItems[0].SubItems[3].Text + "' " +
                              "ORDER BY PositionID";
            cmd.CommandTimeout = 10000;

            if (conn.State == 0)
            {
                if (connPassword.Trim() == "")
                {
                    conn.Open();
                }
                else
                {
                    conn.Open(ExchequerCommonSQLConnection, "", connPassword.Trim(),
                              (int)ADODB.ConnectModeEnum.adModeUnknown);
                }
            }
            conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

            cmd.CommandType      = ADODB.CommandTypeEnum.adCmdText;
            cmd.ActiveConnection = conn;
            ADODB.Recordset recordSet = null;
            object          objRecAff;

            try
            {
                recordSet = (ADODB.Recordset)cmd.Execute(out objRecAff, Type.Missing, (int)ADODB.CommandTypeEnum.adCmdText);
            }
            catch
            {
                throw;
            }

            for (int i = 0; i < recordSet.RecordCount; i++)
            {
                ListViewItem lvItem = new ListViewItem(recordSet.Fields[0].Value);

                lvItem.SubItems.Add(recordSet.Fields[1].Value);
                lvItem.SubItems.Add(recordSet.Fields[2].Value);
                lvItem.SubItems.Add(recordSet.Fields[3].Value.ToString());

                lvDetailedResults.Items.Add(lvItem);

                recordSet.MoveNext();
            }

            if (conn.State == 1)
            {
                conn.Close();
            }

            lvDetailedResults.Visible  = true;
            btnReturnToSummary.Visible = true;

            lvSummaryResults.Visible = false;
        }
Exemplo n.º 14
0
        public void SearchCommentsData()
        {
            string sql;
            string sDate;
            string sQuery;
            int    i;

            if (txt_DATE.RawDate.Length != 8)
            {
                sDate = DateTime.Now.AddDays(-1).ToString("yyyyMMdd");
            }
            else
            {
                sDate = txt_DATE.RawDate;
            }

            sql = "      SELECT  YEAR_PLAN_WGT   ,   YEAR_FIN_WGT    , YEAR_PROD_PROG   ,  ";
            sql = sql + "        YEAR_PROG       ,   YEAR_AVE_NEED   , YEAR_LEFT_DAY    ,  ";
            sql = sql + "        NULL            ,                                         ";
            sql = sql + "        MONTH_PLAN_WGT  ,   MONTH_FIN_WGT   , MONTH_PROD_PROG  ,  ";
            sql = sql + "        MONTH_PROG      ,   MONTH_AVE_NEED  , MONTH_LEFT_DAY   ,  ";
            sql = sql + "        NULL                                                      ";
            sql = sql + "  FROM  gp_zb_mon                                              ";
            sql = sql + " WHERE  PLT                     = 'C3'                            ";
            sql = sql + "   AND  PROD_DATE               = '" + sDate + "'                 ";

            sQuery = sql;

            if (GeneralCommon.M_CN1.State == 0)
            {
                if (!GeneralCommon.GF_DbConnect())
                {
                    return;
                }
            }

            ADODB.Recordset AdoRs = new ADODB.Recordset();
            try
            {
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                while (!AdoRs.EOF)
                {
                    for (int j = 6; j <= 7; j++)
                    {
                        for (i = 2; i <= 14; i += 2)
                        {
                            if (j == 6)
                            {
                                if (!(AdoRs.Fields[i / 2 - 1].Value == null || convertD(AdoRs.Fields[i / 2 - 1].Value.ToString()) == 0))
                                {
                                    ss3.ActiveSheet.Cells[j - 1, i - 1].Text = AdoRs.Fields[i / 2 - 1].Value.ToString();
                                }
                            }
                            else
                            {
                                if (!(AdoRs.Fields[i / 2 + 6].Value == null | convertD(AdoRs.Fields[i / 2 + 6].Value.ToString()) == 0))
                                {
                                    ss3.ActiveSheet.Cells[j - 1, i - 1].Text = AdoRs.Fields[i / 2 + 6].Value.ToString();
                                }
                            }
                        }
                    }
                    AdoRs.MoveNext();
                }

                AdoRs.Close();
                AdoRs = null;

                //判断是不是需要关闭连接对象,有时候该方法是在查询过程中调用,关闭对象会导致框架查询报错 韩超

                GeneralCommon.M_CN1.Close();
            }
            catch (Exception ex)
            {
                // if (GeneralCommon.M_CN1.State != 0) GeneralCommon.M_CN1.Close();
                AdoRs.Close();
                AdoRs = null;
            }
        }
Exemplo n.º 15
0
        public bool Gf_Sp_Display3(ADODB.Connection Conn, FarPoint.Win.Spread.FpSpread oSpread, string sQuery, Collection lColumn, bool MsgChk)
        {
            bool returnValue = false;

            int iCount;
            int iRowCount;
            int iColcount;

            object[,] ArrayRecords;
            ADODB.Recordset AdoRs;
            if (Conn.State == 0)
            {
                if (GeneralCommon.GF_DbConnect() == false)
                {
                    return(false);
                }
            }

            AdoRs = new ADODB.Recordset();
            try
            {
                returnValue = true;

                //if (oSpread.ActiveSheet.RowCount > 0)
                //{
                //    //
                //    //'Hux,修改。
                //    //'解决:Spread有两条数据时,点击列头排序后,再点击Spread插入,Spread行清除时报错。
                //    oSpread.ActiveSheet.AutoSortColumn(0);
                //    oSpread.ActiveSheet.RowCount = 0;
                //}

                //FarPoint.Win.Spread.FpSpread with_1 = oSpread;

                iCount = 0;

                Cursor.Current = Cursors.WaitCursor;
                /////////20130606begin解决保存失败后,第一次查询提示算数运算符溢出的问题
                AdoRs.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                AdoRs.CursorType     = ADODB.CursorTypeEnum.adOpenStatic;
                //AdoRs.CursorType =
                //AdoRs.CursorLocation = ADODB.CursorLocationEnum.adUseServer;


                //AdoRs.Open(sQuery, Conn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, 1);
                AdoRs.Open(sQuery, Conn);
                /////////20130606end


                if (AdoRs.BOF || AdoRs.EOF)
                {
                    if (MsgChk)
                    {
                        GeneralCommon.Gp_MsgBoxDisplay("无法找到该资料..!!!", "I", "");
                    }

                    returnValue = false;
                    AdoRs.Close();
                    AdoRs = null;

                    Cursor.Current = Cursors.Default;
                    return(returnValue);
                }

                int RsRowCount = AdoRs.RecordCount;
                int RsColCount = AdoRs.Fields.Count;
                ArrayRecords = new object[RsRowCount, RsColCount];
                int i = 0;
                while (!AdoRs.EOF)
                {
                    for (int j = 0; j < AdoRs.Fields.Count; j++)
                    {
                        ArrayRecords[i, j] = AdoRs.Fields[j].Value;
                    }
                    i++;
                    AdoRs.MoveNext();
                }

                AdoRs.Close();
                AdoRs = null;

                //此处进行表单数据录入

                int ROW = 0;
                int Col = 0;
                if (ArrayRecords.GetLength(0) != 0)
                {
                    for (iRowCount = 0; iRowCount < ArrayRecords.GetLength(0); iRowCount++)
                    {
                        for (iColcount = 1; iColcount <= 7; iColcount++)
                        {
                            if (substr(ArrayRecords[iRowCount, 0].ToString(), 1, 1) == "0")
                            {
                                Col = 2 * iColcount - 2;
                            }
                            else if (substr(ArrayRecords[iRowCount, 0].ToString(), 1, 1) == "1")
                            {
                                Col = 2 * iColcount - 1;
                            }

                            if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "A")
                            {
                                ROW = 0;
                            }
                            else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "B")
                            {
                                ROW = 1;
                            }
                            else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "C")
                            {
                                ROW = 2;
                            }
                            else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "D")
                            {
                                ROW = 3;
                            }
                            else if (substr(ArrayRecords[iRowCount, 0].ToString(), 0, 1) == "T")
                            {
                                ROW = 4;
                            }

                            if (ArrayRecords[iRowCount, iColcount].ToString() == "" || ArrayRecords[iRowCount, iColcount].ToString() == "0")
                            {
                                oSpread.ActiveSheet.Cells[ROW, Col].Text = "";
                            }
                            else
                            {
                                oSpread.ActiveSheet.Cells[ROW, Col].Text = ArrayRecords[iRowCount, iColcount].ToString();
                            }
                        }
                    }
                }
                Cursor.Current = Cursors.Default;
                ArrayRecords   = null;
            }
            catch (Exception ex)
            {
                AdoRs       = null;
                returnValue = false;
                GeneralCommon.Gp_MsgBoxDisplay((string)("Gf_Sp_Display Error : " + ex.Message), "", "");
                Cursor.Current = Cursors.Default;
                if (Information.Err().Number == 438 || Information.Err().Number == -2147467259)
                {
                    Conn.Close();
                }
            }

            return(returnValue);
        }
Exemplo n.º 16
0
    } // end function;

    public void match_delay_equip(short useval)
    {
        //on error GoTo err_match;

        ADODB.Recordset rec1 = null;
        string          str1;
        int             delay_id;
        int             stand_id;

        //useval = 2 force the match and only in basecase ...;
        if (glngwid != 0)
        {
            return;               //exit  Sub;
        }
        //Open();
        str1 = "SELECT tblequip.* FROM tblequip;";
        DbUse.open_ado_rec(globaldb, ref rec1, str1);

        delay_id = find_nameItem("Delay", 0, Eq_type, 0);
        stand_id = find_nameItem("standard", 0, Eq_type, 0);

        while (!rec1.EOF)
        {
            if ((useval == 0))
            {
                //'  using type to set grpsize;
                if (((int)rec1.Fields["EQUIPTYPE"].Value) == delay_id) // gerg - I'm not sure if this will work, if not try int.Parse(rec1.Fields["EQUIPTYPE"].Value.ToString()) == delay_id
                {
                    rec1.Fields["grpsiz"].Value = -1;
                }
                else if (((short)rec1.Fields["grpsiz"].Value) == -1)
                {
                    //' standard type but grpsiz = -1;
                    rec1.Fields["grpsiz"].Value = 1;
                }
                ;
            }
            else if ((useval == 1))
            {
                if (((short)rec1.Fields["grpsiz"].Value) == -1)
                {
                    rec1.Fields["EQUIPTYPE"].Value = delay_id;
                }
                else if ((int)rec1.Fields["EQUIPTYPE"].Value != delay_id)
                {
                    //' grpsiz = 2, type = delay ??;
                    rec1.Fields["EQUIPTYPE"].Value = stand_id;
                }
                ;
            }
            else if ((useval == 2))
            {
                //'' force to -1 / delay if either is set.;
                if (short.Parse(rec1.Fields["grpsiz"].Value.ToString()) == -1)
                {
                    rec1.Fields["EQUIPTYPE"].Value = delay_id;
                }
                else if ((int)rec1.Fields["EQUIPTYPE"].Value == delay_id)
                {
                    rec1.Fields["grpsiz"].Value = -1;
                }
                ;
            }
            ;

            rec1.Update();
            rec1.MoveNext();
        }
        ;  // end of while ...

        //exit_match:
        DbUse.CloseAdoRec(rec1);
        rec1 = null;
        return; //exit  Sub;
        //err_match: ;
        // msgbox(ErrorToString(), 0, appl_name);
        // resume  exit_match;
    } // end sub;
Exemplo n.º 17
0
        private void CHEMISTRY_DISP()
        {
            if (GeneralCommon.M_CN1.State == 0)
            {
                if (!GeneralCommon.GF_DbConnect())
                {
                    return;
                }
            }

            ADODB.Recordset AdoRs = new ADODB.Recordset();
            string          sQuery;

            sQuery = "SELECT ELEMENT_CD, ELEMENT_VAL FROM NISCO.FP_CHEMISTRY WHERE HEAT_NO = '" + txt_new_slab_no.Text + "' ORDER BY SEQ_NO ";
            try
            {
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                //bool RltValue = false;

                if (!AdoRs.BOF && !AdoRs.EOF)
                {
                    //RltValue = true;
                    while (!AdoRs.EOF)
                    {
                        switch (AdoRs.Fields[0].Value.ToString())
                        {
                        case "C":
                            txt_c.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Mn":
                            txt_mn.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "P":
                            txt_p.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "S":
                            txt_s.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Si":
                            txt_si.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Ceq":
                            txt_ceq.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Nb":
                            txt_nb.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Cu":
                            txt_cu.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "V":
                            txt_v.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Cr":
                            txt_cr.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Ni":
                            txt_ni.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Alt":
                            txt_alt.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Mo":
                            txt_mo.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Ti":
                            txt_ti.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "W":
                            txt_w.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "B":
                            txt_b.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Re":
                            txt_re.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Pb":
                            txt_pb.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Ca":
                            txt_ca.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "N":
                            txt_n.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "H":
                            txt_h.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "O":
                            txt_o.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Als":
                            txt_als.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Zr":
                            txt_zr.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Mg":
                            txt_mg.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Sn":
                            txt_sn.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "As":
                            txt_as.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Co":
                            txt_co.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Te":
                            txt_te.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Bi":
                            txt_bi.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Sb":
                            txt_sb.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Zn":
                            txt_zn.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Se":
                            txt_se.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Ta":
                            txt_ta.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;

                        case "Pcm":
                            txt_pcm.NumValue = Convert.ToDouble(AdoRs.Fields[1].Value);
                            break;
                        }

                        AdoRs.MoveNext();
                    }
                }

                sQuery = "          SELECT STEEL_NET_WGT ";
                sQuery = sQuery + "   FROM NISCO.FP_CHARGE ";
                sQuery = sQuery + "  WHERE HEAT_NO LIKE '" + txt_new_slab_no.Text.Trim() + "%'";

                txt_wgt.NumValue = 0;
                txt_wgt.NumValue = GeneralCommon.Gf_FloatFind(GeneralCommon.M_CN1, sQuery);
                txt_slabcnt.Text = ss1.ActiveSheet.RowCount.ToString();
            }
            catch (Exception ex)
            {
                if (GeneralCommon.M_CN1.State != 0)
                {
                    GeneralCommon.M_CN1.Close();
                }
                AdoRs = null;
                //RltValue = false;
                GeneralCommon.Gp_MsgBoxDisplay("数据读取失败" + ex.Message, "", "");
            }
        }
Exemplo n.º 18
0
        private static List <AssetHistory> ProcessAssetHistoryRS(ADODB.Recordset _ors, GTDiagnostics _odiag)
        {
            List <AssetHistory> histList = null;
            int g3eFid;

            try
            {
                AssetHistory obj = null;
                histList = new List <AssetHistory>();

                while ((!_ors.EOF) && (!_ors.BOF))
                {
                    obj         = new AssetHistory();
                    obj.G3E_FID = Convert.ToInt32(_ors.Fields["G3E_FID"].Value.ToString().Trim());
                    g3eFid      = obj.G3E_FID;
                    obj.G3E_FNO = Convert.ToInt16(_ors.Fields["G3E_FNO"].Value.ToString().Trim());

                    string sCNO = _ors.Fields["G3E_CNO"].Value.ToString().Trim();
                    if (!string.IsNullOrEmpty(sCNO))
                    {
                        obj.G3E_CNO = Convert.ToInt16(sCNO);
                    }
                    else
                    {
                        obj.G3E_CNO = 0;
                    }

                    string sANO = _ors.Fields["G3E_ANO"].Value.ToString().Trim();
                    if (!string.IsNullOrEmpty(sANO))
                    {
                        obj.G3E_ANO = Convert.ToInt32(sANO);
                    }
                    else
                    {
                        obj.G3E_ANO = 0;
                    }


                    string sCID = _ors.Fields["G3E_CID"].Value.ToString().Trim();
                    if (!string.IsNullOrEmpty(sCID))
                    {
                        obj.G3E_CID = Convert.ToInt32(sCID);
                    }
                    else
                    {
                        obj.G3E_CID = 0;
                    }

                    obj.StructureID_1 = _ors.Fields["STRUCTURE_ID_1"].Value.ToString().Trim();

                    string sx = _ors.Fields["OGG_X_1"].Value.ToString().Trim();
                    if (string.IsNullOrEmpty(sx))
                    {
                        LogMessage(_odiag, "ProcessAssetHistoryRS", "LocationXYZ", "No location for x value for fid = " + obj.G3E_FID.ToString());
                        obj = null;
                    }
                    string sy = _ors.Fields["OGG_Y_1"].Value.ToString().Trim();
                    if (string.IsNullOrEmpty(sy))
                    {
                        LogMessage(_odiag, "ProcessAssetHistoryRS", "LocationXYZ", "No location for y value for fid = " + g3eFid);
                        obj = null;
                    }
                    if (obj != null)
                    {
                        obj.OGG_X1 = Convert.ToDouble(sx);
                        obj.OGG_Y1 = Convert.ToDouble(sy);


                        string sz = _ors.Fields["OGG_Z_1"].Value.ToString().Trim();
                        if (!string.IsNullOrEmpty(sz))
                        {
                            obj.OGG_Z1 = Convert.ToDouble(sz);
                        }
                        else
                        {
                            obj.OGG_Z1 = 0;
                        }

                        string oldValue = _ors.Fields["VALUE_OLD"].Value.ToString().Trim();
                        if (!string.IsNullOrEmpty(oldValue))
                        {
                            obj.OLD_VALUE = oldValue;
                        }

                        string newValue = _ors.Fields["VALUE_NEW"].Value.ToString().Trim();
                        if (!string.IsNullOrEmpty(newValue))
                        {
                            obj.NEW_VALUE = newValue;
                        }

                        obj.ChangeOperation = _ors.Fields["CHANGE_OPERATION"].Value.ToString().Trim();
                        string   sChangeDate = _ors.Fields["CHANGE_DATE"].Value.ToString().Trim();
                        DateTime changedate;
                        DateTime.TryParse(sChangeDate, out changedate);
                        obj.ChangeDate = changedate;

                        histList.Add(obj);
                    }
                    _ors.MoveNext();
                }

                if (histList.Count == 0)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogException(_odiag, "ProcessAssetHistoryRS", ex);
                throw ex;
            }

            return(histList);
        }
Exemplo n.º 19
0
        //日期格式
        public string Gf_DTSet(string DTCheck, string DTFlag)
        {
            if (DTCheck == "D")
            {
                DTCheck = "D";
            }
            else
            {
                DTCheck = "S";
            }
            DTFlag = "C";

            string sQuery     = "";
            int    sQuery_Len = 0;
            string time       = "";

            switch (DTCheck)
            {
            case "S":
                sQuery     = "SELECT TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') FROM DUAL";
                sQuery_Len = 14;
                break;

            case "I":
                sQuery     = "SELECT TO_CHAR(SYSDATE,'YYYYMMDDHH24MI') FROM DUAL";
                sQuery_Len = 12;
                break;

            case "H":
                sQuery     = "SELECT TO_CHAR(SYSDATE,'YYYYMMDDHH24') FROM DUAL";
                sQuery_Len = 10;
                break;

            case "D":
                sQuery     = "SELECT TO_CHAR(SYSDATE,'YYYYMMDD') FROM DUAL";
                sQuery_Len = 8;
                break;

            case "T":
                sQuery     = "SELECT TO_CHAR(SYSDATE,'HH24MISS') FROM DUAL";
                sQuery_Len = 6;
                break;

            case "M":
                sQuery     = "SELECT TO_CHAR(SYSDATE,'YYYYMM') FROM DUAL";
                sQuery_Len = 6;
                break;

            case "Y":
                sQuery     = "SELECT TO_CHAR(SYSDATE,'YYYY') FROM DUAL";
                sQuery_Len = 4;
                break;
            }

            if (DTFlag == "C")
            {
                if (DTCheck == "T")
                {
                    return(DateTime.Now.ToString("HHmmss"));
                }
                return((DateTime.Now.ToString("yyyyMMddHHmmss")).Substring(0, sQuery_Len));
            }

            if (GeneralCommon.M_CN1.State == 0)
            {
                if (!GeneralCommon.GF_DbConnect())
                {
                    return("00000000000000");
                }
            }

            ADODB.Recordset AdoRs = new ADODB.Recordset();
            try
            {
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                if (!AdoRs.BOF && !AdoRs.EOF)
                {
                    //RltValue = true;
                    while (!AdoRs.EOF)
                    {
                        if (AdoRs.Fields[0].Value.ToString() == "")
                        {
                            time = "";
                        }
                        else
                        {
                            time = AdoRs.Fields[0].Value.ToString();
                        }
                        AdoRs.MoveNext();
                    }
                }
                else
                {
                    time = "00000000000000";
                }

                GeneralCommon.M_CN1.Close();

                AdoRs = null;

                return(time);
            }
            catch (Exception ex)
            {
                if (GeneralCommon.M_CN1.State != 0)
                {
                    GeneralCommon.M_CN1.Close();
                }
                AdoRs = null;
                return("00000000000000");
            }
        }
Exemplo n.º 20
0
        private void ExecuteSql(ThreadObj Param)
        {
            string query = Param.Query;

            // new recordset reference
            ADODB.Recordset Data = null;

            // keep a connection reference
            ADODB.Connection Connect = null;

            try
            {
                // change cursor to wait cursor
                this.Invoke(ChangeCursorDel, new object[] { Cursors.WaitCursor });

                // initialize the message string to be empty
                string Message  = "";
                string Warnings = "";

                // keep track of the max number of columns
                int nMaxNumCols = 0;

                // fill in a data table with our results
                DataTable SqlResults = new DataTable();

                // open the connection
                Connect = new Connection();
                Connect.ConnectionString = Param.ConnectionString;
                Connect.CursorLocation   = CursorLocationEnum.adUseClient;
                Connect.Open();

                // initialize an object to store the number of records affected
                object obRecsAffected;

                // number of queries returned so far is none
                int nQueriesReturned = 0;

                // construct a command object
                ADODB.Command SqlCmd = new Command();
                SqlCmd.ActiveConnection = Connect;
                SqlCmd.CommandText      = (string)query;
                SqlCmd.CommandType      = CommandTypeEnum.adCmdText;

                // execute the sql statement
                Data = Connect.Execute((string)query, out obRecsAffected);

                // while there are recordsets
                while (Data != null)
                {
                    // for this query, print out all the errors that occurred
                    foreach (ADODB.Error e in Connect.Errors)
                    {
                        Warnings += e.Description + "\r\n";
                    }

                    // we have another query, increment the count
                    nQueriesReturned++;

                    // if there is something to read (hence the object is not closed)...
                    if ((ADODB.ObjectStateEnum)Data.State != ADODB.ObjectStateEnum.adStateClosed)
                    {
                        // count of rows retrieved
                        int nRowsRecieved = 0;

                        // if this recordset has more columns in it than previous columns
                        for (int i = nMaxNumCols; i < Data.Fields.Count; i++)
                        {
                            // add a column and increment the max col count
                            DataColumn temp = new DataColumn(Data.Fields[i].Name, typeof(string));
                            SqlResults.Columns.Add(temp);
                            nMaxNumCols++;
                        }

                        // grab the current time in ticks
                        long InitialTime = DateTime.Now.Ticks;

                        // while there is stuff in the recordset
                        while (!Data.EOF)
                        {
                            // create a new row
                            DataRow tempRow = SqlResults.NewRow();

                            // fill each column with data
                            for (int i = 0; i < Data.Fields.Count; i++)
                            {
                                tempRow[i] = Data.Fields[i].Value.ToString();
                            }

                            // add it to the results
                            SqlResults.Rows.Add(tempRow);

                            nRowsRecieved++;

                            // if the user didnt cancel, display the record number being loaded, otherwise the user did cancel so stop doing work
                            if (!m_bUserCancel)
                            {
                                this.Invoke(SetResultsDel, new object[] { String.Format("Loading Record {0} in Query {1}...", nRowsRecieved, nQueriesReturned), false });
                            }
                            else
                            {
                                this.Invoke(SetResultsDel, new object[] { "Canceling... Please wait...", false });
                                break;
                            }

                            // continue to the next record in the recordset
                            Data.MoveNext();
                        }

                        // the time elapsed is the time now minus the initial
                        double TimeElapsed = ((float)(DateTime.Now.Ticks - InitialTime)) / 10000000.0;

                        // add the number of rows returned and how long it took to the messages to display once the results are ready to be displayed
                        Message += nQueriesReturned + ": " + nRowsRecieved + " row(s) returned. " + String.Format("({0:0.0000} seconds)", TimeElapsed) + "\r\n";
                    }
                    else
                    {
                        // otherwise, it was a non action query, so records must have been affected
                        Message += nQueriesReturned + ": " + (int)obRecsAffected + " record(s) affected.\r\n";
                    }

                    // if the user canceled, just return the form to its original state and state that the user canceled
                    if (m_bUserCancel)
                    {
                        this.Invoke(SetUpFormDel, new object[] { true });
                        this.Invoke(ShowResultsDel, new object[] { SqlResults, Message });
                        this.Invoke(SetResultsDel, new object[] { "Loading Was Canceled by User.", true });
                        return;
                    }

                    // try to go to the next recordset
                    try
                    {
                        Data = Data.NextRecordset(out obRecsAffected);
                    }
                    catch (COMException ex)
                    {
                        // if for some reason, the provider doesnt like that, just break out on the first recordset
                        if (ex.ErrorCode == -2146825037)
                        {
                            Data = null;
                        }
                        else
                        {
                            // otherwise, just rethrow our excetion, its a bigger problem
                            throw ex;
                        }
                    }
                }

                this.Invoke(SetMessageDel, new object[] { Warnings.Trim() });

                // after all records have been run through, go ahead and show the results
                this.Invoke(ShowResultsDel, new object[] { SqlResults, Message });
            }
            catch (Exception ex)
            {
                string ErrorText = "";
                if (Connect.Errors.Count > 0)
                {
                    // for this query, print out all the errors that occurred
                    foreach (ADODB.Error e in Connect.Errors)
                    {
                        ErrorText += "Error " + e.Number + ": " + e.Description + "\r\n";
                    }

                    Connect.Errors.Clear();
                }
                else
                {
                    ErrorText = "Error: " + ex.Message;
                }

                // if any exception does happen, dont display results, but print out the error
                this.Invoke(SetResultsDel, new object[] { ErrorText.Trim(), true });
                this.Invoke(SetUpFormDel, new object[] { true });

                // change cursor to default cursor
                this.Invoke(ChangeCursorDel, new object[] { Cursors.Default });
                return;
            }
            finally
            {
                if (Data != null && Data.State != (int)ConnectionState.Closed)
                {
                    Data.Close();
                }
            }
        }
Exemplo n.º 21
0
        private void CreateSpreadSheet(ADODB.Recordset objRS, string strPath)
        {
            Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
            Workbook  xlWB     = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            Sheets    xlSheets = xlWB.Worksheets;
            Worksheet xlWS     = new Worksheet();

            xlWS = xlSheets.get_Item(1);
            //adding headers to spreadsheet
            xlWS.Columns["AM"].NumberFormat = "@";


            int t = 1;

            while (objRS.EOF != true)
            {
                for (int j = 0; j < objRS.Fields.Count; j++)
                {
                    if (t == 1)
                    {
                        xlWS.Cells.set_Item(t, j + 1, objRS.Fields[j].Name.ToString());
                    }
                    // try - to catch bogus data that might appear in recordset (bad characters, etc.)
                    try
                    {
                        xlWS.Cells.set_Item(t + 1, j + 1, objRS.Fields[j].Value);
                    }
                    catch
                    {
                        xlWS.Cells.set_Item(t + 1, j + 1, "");
                    }
                }

                if (objRS.EOF != true)
                {
                    objRS.MoveNext();
                    t++;
                }
            }


            xlWS.Columns.AutoFit();
            if (File.Exists(strPath))
            {
                File.Delete(strPath);
            }

            xlWB.SaveAs(strPath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

            //Kill excel object from memory
            xlWB.Close();
            xlApp.Quit();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWS);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlWB);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);


            xlWS  = null;
            xlWB  = null;
            xlApp = null;

            GC.GetTotalMemory(false);
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.GetTotalMemory(true);
        }
Exemplo n.º 22
0
        private bool IsColumnPrimaryKey(string name, string column)
        {
            if (radioSql.Checked)
            {
                int     tableid = Gateway.Default.SelectScalar <int>("select id from sysobjects where [name] = @name", new object[] { name });
                DataSet ds      = Gateway.Default.SelectDataSet("select a.name FROM syscolumns a inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' where (SELECT count(*) FROM sysobjects WHERE (name in (SELECT name FROM sysindexes WHERE (id = a.id) AND (indid in (SELECT indid FROM sysindexkeys WHERE (id = a.id) AND (colid in (SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a.name))))))) AND (xtype = 'PK'))>0 and d.id = @id", new object[] { tableid });
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i][0].ToString() == column)
                    {
                        return(true);
                    }
                }
            }
            else if (radioOracle.Checked)
            {
                DataSet ds = Gateway.Default.SelectDataSet("select b.COLUMN_NAME from USER_CONSTRAINTS a,USER_CONS_COLUMNS b where a.CONSTRAINT_NAME=b.CONSTRAINT_NAME and a.table_name=b.table_name and constraint_type='P' and a.owner=b.owner and a.table_name = :name", new object[] { name });
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i][0].ToString() == column)
                    {
                        return(true);
                    }
                }
            }
            else if (radioMySql.Checked)
            {
                System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("(^.*database=)([^;]+)(;.*)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                string dbName = r.Replace(txtConnStr.Text, "$2").ToLower();

                DataSet ds = Gateway.Default.SelectDataSet("select COLUMN_NAME from KEY_COLUMN_USAGE where CONSTRAINT_SCHEMA = '" + dbName + "' and CONSTRAINT_NAME = 'PRIMARY' and TABLE_NAME = ?TABLE_NAME", new object[] { name });
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i][0].ToString() == column)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
                conn.Provider = "Microsoft.Jet.OLEDB.4.0";
                string connStr = txtConnStr.Text;
                conn.Open(connStr.Substring(connStr.ToLower().IndexOf("data source") + "data source".Length).Trim('=', ' '), null, null, 0);

                ADODB.Recordset rs = conn.GetType().InvokeMember("OpenSchema", BindingFlags.InvokeMethod, null, conn, new object[] { ADODB.SchemaEnum.adSchemaPrimaryKeys }) as ADODB.Recordset;
                rs.Filter = "TABLE_NAME='" + name + "'";

                while (!rs.EOF)
                {
                    if ((rs.Fields["COLUMN_NAME"].Value as string) == column)
                    {
                        return(true);
                    }

                    rs.MoveNext();
                }
            }

            return(false);
        }
Exemplo n.º 23
0
        private void enablemenu()
        {
            ADODB.Connection ADOconn = new ADODB.Connection();
            ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0);
            ADODB.Recordset cus = new ADODB.Recordset();

            cus = new ADODB.Recordset();
            //string sql = "SELECT menu_code FROM menu_master where id in (select form_id from userpriv where dsp=1 and group_name = (select group_name from userinfo where userid='" + Gvar.Userid+ "'))";
            string sql = "SELECT m.menu_code,p.* FROM menu_master as M inner join userpriv as p on  m.id=p.form_id where p.dsp=1 and p.group_name = (select group_name from userinfo where userid='" + Gvar.Userid + "')";

            cus.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1);
            while (!cus.EOF)
            {
                string    mnu = cus.Fields[0].Value.ToString();
                string    prv;
                Gvar.Priv menu_item = new Gvar.Priv();

                if (string.IsNullOrEmpty(cus.Fields["ins"].Value.ToString()))
                {
                    cus.Fields["ins"].Value = 0;
                }
                if (string.IsNullOrEmpty(cus.Fields["upd"].Value.ToString()))
                {
                    cus.Fields["upd"].Value = 0;
                }
                if (string.IsNullOrEmpty(cus.Fields["del"].Value.ToString()))
                {
                    cus.Fields["del"].Value = 0;
                }


                if ((bool)cus.Fields["ins"].Value)
                {
                    prv = "1";
                }
                else
                {
                    prv = "0";
                }
                if ((bool)cus.Fields["upd"].Value)
                {
                    prv = prv + "1";
                }
                else
                {
                    prv = prv + "0";
                }
                if ((bool)cus.Fields["del"].Value)
                {
                    prv = prv + "1";
                }
                else
                {
                    prv = prv + "0";
                }
                lstmenu.Items.Add(mnu);
                lstpriv.Items.Add(prv);
                menu_item.Menu = mnu;
                menu_item.priv = prv;

                Gvar.User_Priv.Add(menu_item);
                cus.MoveNext();

                ////foreach (ToolStripMenuItem toolSripItem in menuStrip.Items)
                ////{
                ////    if (toolSripItem.HasDropDownItems)
                ////    {
                ////        foreach (ToolStripItem toolSripItem1 in toolSripItem.DropDownItems)
                ////        {
                ////            if (toolSripItem1 is ToolStripSeparator) continue;

                ////            if (toolSripItem1 is ToolStripMenuItem)
                ////                //    insert_menu(menuItem.Text, toolSripItem.Name, 1, toolSripItem.Text, "", 'A');

                ////                if (toolSripItem1.Name==mnu)

                ////                toolSripItem.Visible = true;
                ////            {                        //call recursively
                ////               // disableMenu((ToolStripMenuItem)toolSripItem);
                ////            }
                ////        }
                ////    }

                ////}
            }
            ADOconn.Close();
            //cus.Close();
        }
Exemplo n.º 24
0
        public static string build_sms(ADODB.Recordset rec)
        {
            SqlConnectionStringBuilder decoder = new SqlConnectionStringBuilder(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ConnectionString);

            ADODB.Connection ADOconn = new ADODB.Connection();
            ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0);

            string sql;


            sql = "SELECT * from sms_ini";

            ADODB.Recordset sms = new Recordset();

            sms.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1);



            string post_data = sms.Fields["sms_parameter"].Value.ToString();

            //post_data = post_data.Replace("$strlang", cb_sms_lang.SelectedIndex.ToString());
            post_data = post_data.Replace("$smsid", sms.Fields["sms_header"].Value.ToString());

            while (!rec.EOF)
            {
                string mob_no = rec.Fields["ACC_MOBILE_NO"].Value.ToString().Trim();
                if (mob_no.Length > 9)
                {
                    mob_no = "966" + mob_no.Substring(mob_no.Length - 9);
                }
                else
                {
                    mob_no = "0";
                    return("");
                }
                // == "\r\n"
                post_data = post_data.Replace("$mobileno", mob_no);
                post_data = post_data.Replace("$smsid", sms.Fields["sms_header"].Value.ToString());
                string mesg = "";

                mesg = sms.Fields["sms_customer_en"].Value.ToString();
                mesg = mesg.Replace("$payamt", rec.Fields["payamt"].Value.ToString());
                mesg = mesg.Replace("$balamt", rec.Fields["balamt"].Value.ToString());

                mesg = mesg.Replace("#", "\n");

                string responseString = Send_Sms(sms.Fields["sms_url"].Value.ToString(), post_data, mesg, 0);

                // Task taskA = new Task( () => Send_Sms(sms.Fields["sms_url"].Value.ToString(), post_data, mesg,1));
                //Start the task.
                // taskA.Start();
                // taskA.Wait();

                rec.MoveNext();
            }
            return("");



            //foreach (DataRowView r in sms)
            //{

            //    if (!Validation.IsNull(r["sms_ini"]))


            //         r["veh_model_code"] [0][0];
            //}
        }
Exemplo n.º 25
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            ADODB.Recordset  rsMail         = null;
            ADODB.Recordset  rsContract     = null;
            ADODB.Recordset  rsMailSettings = null;
            ADODB.Connection connDb         = null;
            bool             solde          = false;
            string           destinataire   = "";
            bool             contratEchu    = false;
            string           CONN_DB        = "";

            //   if (args==null)
            //      Application.Exit();
            if (args == null)
            {
                CONN_DB = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\lementor\StudiosUnis\LeMentorÉlèveTables.mdb;";
            }
            else
            {
                CONN_DB = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + args;
            }


            try
            {
                connDb         = new ADODB.Connection();
                rsMail         = new ADODB.Recordset();
                rsMailSettings = new ADODB.Recordset();
                rsContract     = new ADODB.Recordset();
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                client.UseDefaultCredentials = false;
                client.EnableSsl             = true;
                client.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;

                System.Net.Mail.MailMessage msg = null;
                connDb.Open(CONN_DB);
                rsMail.Open("select * from emailmessage", connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic);
                rsMailSettings.Open("select * from cie", connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic);
                if (!rsMail.EOF)
                {
                    rsMail.MoveFirst();
                }
                if (!rsMailSettings.EOF)
                {
                    rsMailSettings.MoveFirst();
                    client.Port        = rsMailSettings.Fields["PortSmtp"].Value; // rsMailSettings.Fields["PortSmtp"].Value;
                    client.Host        = rsMailSettings.Fields["ServerSmtp"].Value.ToString();
                    client.Credentials = new System.Net.NetworkCredential(rsMailSettings.Fields["E-mail"].Value.ToString(), rsMailSettings.Fields["MotdePasseE-mail"].Value);
                }

                while (!rsMail.EOF)
                {
                    solde       = rsMail.Fields["solde"].Value;
                    contratEchu = rsMail.Fields["contratechu"].Value;

                    //destinataire = rsMail.Fields["destinataire"].Value.ToString();

                    // destinataire = "dquirion78@@gmail.com";
                    msg            = new System.Net.Mail.MailMessage();
                    msg.From       = new MailAddress(rsMailSettings.Fields["e-mail"].Value.ToString());
                    msg.Subject    = rsMail.Fields["sujet"].Value.ToString();
                    msg.Body       = rsMail.Fields["texte"].Value.ToString();
                    msg.IsBodyHtml = false;

                    if (string.IsNullOrEmpty(rsMail.Fields["destinataire"].Value.ToString()))
                    {
                        throw new Exception("Destinataire Manquant!");
                    }
                    else
                    {
                        msg.To.Add(destinataire);
                    }
                    if (!string.IsNullOrEmpty(rsMail.Fields["cc"].Value.ToString()))
                    {
                        msg.CC.Add(rsMail.Fields["cc"].Value.ToString());
                    }

                    if (!string.IsNullOrEmpty(rsMail.Fields["cci"].Value.ToString()))
                    {
                        msg.Bcc.Add(rsMail.Fields["cci"].Value.ToString());
                    }
                    if (rsMail.Fields["fichier"].Value.ToString().Length > 3)
                    {
                        System.Net.Mail.Attachment attachment;
                        attachment = new System.Net.Mail.Attachment(rsMail.Fields["fichier"].Value.ToString());
                        msg.Attachments.Add(attachment);
                    }
                    client.Send(msg);
                    // if (rsMail.Fields["fichier"].Value.ToString().Length > 3)
                    //   File.Delete(rsMail.Fields["fichier"].Value.ToString());
                    msg = null;
                    rsContract.Open("select * from GA_Eleve_Cours where [noidcours] =" + rsMail.Fields["noidcours"].Value.ToString(), connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic);
                    if (!rsContract.EOF)
                    {
                        rsContract.MoveFirst();
                        if (rsMail.Fields["ContratEchu"].Value == true)
                        {
                            rsContract.Fields["NotficationContratEchu"].Value = true;
                        }
                        if (rsMail.Fields["solde"].Value == true)
                        {
                            rsContract.Fields["DernDateNotificationsolde"].Value = rsMail.Fields["DernDateNotificationsolde"].Value;
                            rsContract.Fields["NbreNotificationsolde"].Value     = rsMail.Fields["NbreNotificationsolde"].Value;
                        }
                        rsContract.Update();
                    }
                    rsContract.Close();
                    rsMail.Delete();
                    rsMail.MoveNext();
                    if (!rsMail.EOF)
                    {
                        System.Threading.Thread.Sleep(5000);//limite les chances d'être taggé comme spam par le fournisseur d'envoi en envoyant pas trop vite les emails.
                    }
                    //msg.CC.Add(Email);
                }


                /*
                 *      if (Attachments.Count() > 0)
                 *      {
                 *        foreach (var item in Attachments)
                 *        {
                 *          if (!string.IsNullOrEmpty(item))
                 *          {
                 *            System.Net.Mail.Attachment attachment;
                 *            attachment = new System.Net.Mail.Attachment(item);
                 *            msg.Attachments.Add(attachment);
                 *          }
                 *        }
                 *      }
                 */
                if (((solde == false && contratEchu == false) || (rsMail.RecordCount == 1)) && destinataire.Length > 0)
                {
                    MessageBox.Show("Message Envoyé : à " + destinataire);
                    Application.Exit();
                }

                else
                {
                    //  MessageBox.Show("Message Envoyé : à " + rsMail.RecordCount.ToString() + " clients.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show("ÉCHEC d'envoi de courier !");
                Application.Exit();
            }

            try
            {
                if (rsMail.State != 0)
                {
                    rsMail.Close();
                }

                rsMail = null;
                if (rsMailSettings.State != 0)
                {
                    rsMailSettings.Close();
                }
                rsMailSettings = null;
                if (rsContract.State != 0)
                {
                    rsContract.Close();
                }
                rsContract = null;
                Application.Exit();
            }
            catch
            {
                Application.Exit();
            }
        }
Exemplo n.º 26
0
        public string Gf_ShiftSet3(string WKDATE)
        {
            if (GeneralCommon.M_CN1.State == 0)
            {
                if (!GeneralCommon.GF_DbConnect())
                {
                    return("");
                }
            }
            string Shift_HH = "0";
            string sQuery;

            sQuery = "SELECT TO_CHAR(SYSDATE,'HH24MI') FROM DUAL";
            ADODB.Recordset AdoRs = new ADODB.Recordset();
            try
            {
                if (WKDATE != "")
                {
                    return(WKDATE);
                }
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                if (!AdoRs.BOF && !AdoRs.EOF)
                {
                    //RltValue = true;
                    while (!AdoRs.EOF)
                    {
                        if (AdoRs.Fields[0].Value.ToString() == "")
                        {
                            Shift_HH = "";
                        }
                        else
                        {
                            Shift_HH = AdoRs.Fields[0].Value.ToString();
                        }
                        AdoRs.MoveNext();
                    }
                }
                GeneralCommon.M_CN1.Close();
                AdoRs = null;

                if (Convert.ToInt32(Shift_HH) < 800)
                {
                    return("1");
                }
                else if (Convert.ToInt32(Shift_HH) < 1600)
                {
                    return("2");
                }
                else
                {
                    return("3");
                }
            }
            catch (Exception ex)
            {
                if (GeneralCommon.M_CN1.State != 0)
                {
                    GeneralCommon.M_CN1.Close();
                }
                AdoRs = null;
                return("0");
            }
        }
Exemplo n.º 27
0
        private void DisplayResults()
        {
            lvSummaryResults.Items.Clear();

            //SS:01/03/2018:2018-R1:ABSEXCH-19796: When Running the ExchDVT.exe, SQL Admin Passwords are visible in dump file.
            ADODB.Connection conn = new ADODB.Connection();
            ADODB.Command    cmd  = new ADODB.Command();
            cmd.CommandText = "SELECT [IntegrityErrorCode] " +
                              ", [SummaryDescription] = CONVERT(VARCHAR(100), count(IntegrityErrorCode)) + ' ' + [IntegritySummaryDescription] " +
                              ", [Severity] " +
                              ", [SchemaName] " +
                              ", [TableName] " +
                              "FROM [common].[SQLDataValidation] " +
                              "GROUP BY SchemaName, Severity, IntegrityErrorCode, IntegritySummaryDescription, TableName " +
                              "ORDER BY SchemaName, Severity, IntegrityErrorCode";
            cmd.CommandTimeout = 10000;

            if (conn.State == 0)
            {
                if (connPassword.Trim() == "")
                {
                    conn.Open();
                }
                else
                {
                    conn.Open(ExchequerCommonSQLConnection, "", connPassword.Trim(),
                              (int)ADODB.ConnectModeEnum.adModeUnknown);
                }
            }
            conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

            cmd.CommandType      = ADODB.CommandTypeEnum.adCmdText;
            cmd.ActiveConnection = conn;
            ADODB.Recordset recordSet = null;
            object          objRecAff;

            try
            {
                recordSet = (ADODB.Recordset)cmd.Execute(out objRecAff, Type.Missing, (int)ADODB.CommandTypeEnum.adCmdText);
            }
            catch
            {
                throw;
            }

            for (int i = 0; i < recordSet.RecordCount; i++)
            {
                ListViewItem lvItem = new ListViewItem(recordSet.Fields[0].Value);

                lvItem.SubItems.Add(recordSet.Fields[1].Value);
                lvItem.SubItems.Add(recordSet.Fields[2].Value);
                lvItem.SubItems.Add(recordSet.Fields[3].Value);
                lvItem.SubItems.Add(recordSet.Fields[4].Value);

                lvSummaryResults.Items.Add(lvItem);

                recordSet.MoveNext();
            }

            if (conn.State == 1)
            {
                conn.Close();
            }

            // Set INI file based on results of each company
            foreach (ListViewItem lvItem in lvCompanies.CheckedItems)
            {
                tsCheckStatus.Text = "Updating INI file: " + lvItem.SubItems[1].Text.TrimEnd();
                Thread.Sleep(1000);
                Application.DoEvents();

                //SS:01/03/2018:2018-R1:ABSEXCH-19796: When Running the ExchDVT.exe, SQL Admin Passwords are visible in dump file.
                conn = new ADODB.Connection();

                Command command = new ADODB.Command();
                command.CommandText = "SELECT RCount = COUNT(*) " +
                                      "FROM [common].[SQLDataValidation] " +
                                      "WHERE UPPER(Severity) = 'HIGH' " +
                                      "AND SchemaName = '" + lvItem.SubItems[1].Text.TrimEnd() + "'";

                command.CommandTimeout = 10000;

                if (conn.State == 0)
                {
                    if (connPassword.Trim() == "")
                    {
                        conn.Open();
                    }
                    else
                    {
                        conn.Open(ExchequerCommonSQLConnection, "", connPassword.Trim(),
                                  (int)ADODB.ConnectModeEnum.adModeUnknown);
                    }
                }
                conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

                command.ActiveConnection = conn;
                ADODB.Recordset rs = null;
                Object          objAff;

                try
                {
                    rs = (ADODB.Recordset)command.Execute(out objAff, Type.Missing, (int)ADODB.CommandTypeEnum.adCmdText);
                }
                catch
                {
                    throw;
                }

                {
                    if (Convert.ToInt32(rs.Fields["RCount"].Value) == 0)
                    {
                        // Posting Enabled
                        tsCheckStatus.Text = "Posting Enabled: " + lvItem.SubItems[1].Text.TrimEnd();
                        Thread.Sleep(1000);
                        Application.DoEvents();
                        PostingEnabledDisabled(true, lvItem.SubItems[1].Text.TrimEnd());
                        lvItem.SubItems[4].Text = "Enabled";
                    }
                    else
                    {
                        // Posting Disabled
                        tsCheckStatus.Text = "Posting Disabled: " + lvItem.SubItems[1].Text.TrimEnd();
                        Thread.Sleep(1000);
                        Application.DoEvents();
                        PostingEnabledDisabled(false, lvItem.SubItems[1].Text.TrimEnd());
                        lvItem.SubItems[4].Text = "Disabled";
                    }
                }
                if (conn.State == 1)
                {
                    conn.Close();
                }
            }
            tsCheckStatus.Text = "Check Complete";
            Thread.Sleep(1000);
            Application.DoEvents();
        }
Exemplo n.º 28
0
        public void Get_OldSms_Info()
        {
            string tmHeatNo;
            string sQuery;

            sQuery = "          SELECT HEAT_NO ";
            sQuery = sQuery + "   FROM NISCO.FP_CHARGE ";
            sQuery = sQuery + "  WHERE HEAT_NO LIKE '" + txt_new_slab_no.Text.Trim() + "%'";

            tmHeatNo = GeneralCommon.Gf_FloatFind(GeneralCommon.M_CN1, sQuery).ToString();
            if (tmHeatNo.Trim() != "0")
            {
                return;
            }

            sQuery = "SELECT * FROM NISCO.GP_OLDSMSCHEMIF  WHERE NEW_HEAT_NO = '" + txt_new_slab_no.Text.Trim() + "'";

            ADODB.Recordset AdoRs = new ADODB.Recordset();
            //bool RltValue = false;

            try
            {
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                //bool RltValue = false;

                if (!AdoRs.BOF && !AdoRs.EOF)
                {
                    //RltValue = true;
                    while (!AdoRs.EOF)
                    {
                        txt_act_stlgrd_dec.Text = AdoRs.Fields[5].Value.ToString();
                        txt_thk.NumValue        = Convert.ToDouble(AdoRs.Fields[6].Value);
                        txt_wid.NumValue        = Convert.ToDouble(AdoRs.Fields[7].Value);
                        txt_len.NumValue        = Convert.ToDouble(AdoRs.Fields[8].Value);
                        txt_wgt.NumValue        = Convert.ToDouble(AdoRs.Fields[9].Value);
                        txt_slabcnt.NumValue    = Convert.ToDouble(AdoRs.Fields[10].Value);

                        txt_car_no.Text  = AdoRs.Fields[13].Value == "" ? "0" : AdoRs.Fields[13].Value.ToString();
                        txt_c.NumValue   = AdoRs.Fields[14].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[14].Value);
                        txt_si.NumValue  = AdoRs.Fields[15].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[15].Value);
                        txt_mn.NumValue  = AdoRs.Fields[16].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[16].Value);
                        txt_p.NumValue   = AdoRs.Fields[17].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[17].Value);
                        txt_s.NumValue   = AdoRs.Fields[18].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[18].Value);
                        txt_cu.NumValue  = AdoRs.Fields[19].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[19].Value);
                        txt_alt.NumValue = AdoRs.Fields[20].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[20].Value);
                        txt_als.NumValue = AdoRs.Fields[21].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[21].Value);
                        txt_b.NumValue   = AdoRs.Fields[22].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[22].Value);
                        txt_ni.NumValue  = AdoRs.Fields[23].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[23].Value);
                        txt_cr.NumValue  = AdoRs.Fields[24].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[24].Value);
                        txt_mo.NumValue  = AdoRs.Fields[25].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[25].Value);
                        txt_w.NumValue   = AdoRs.Fields[26].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[26].Value);
                        txt_ti.NumValue  = AdoRs.Fields[27].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[27].Value);
                        txt_v.NumValue   = AdoRs.Fields[28].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[28].Value);
                        txt_zr.NumValue  = AdoRs.Fields[29].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[29].Value);
                        txt_pb.NumValue  = AdoRs.Fields[30].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[30].Value);
                        txt_sn.NumValue  = AdoRs.Fields[31].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[31].Value);
                        txt_as.NumValue  = AdoRs.Fields[32].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[32].Value);
                        txt_ca.NumValue  = AdoRs.Fields[33].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[33].Value);
                        txt_co.NumValue  = AdoRs.Fields[34].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[34].Value);
                        txt_mg.NumValue  = AdoRs.Fields[35].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[35].Value);
                        txt_te.NumValue  = AdoRs.Fields[36].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[36].Value);
                        txt_bi.NumValue  = AdoRs.Fields[37].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[37].Value);
                        txt_sb.NumValue  = AdoRs.Fields[38].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[38].Value);
                        txt_zn.NumValue  = AdoRs.Fields[39].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[39].Value);
                        txt_nb.NumValue  = AdoRs.Fields[40].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[40].Value);
                        txt_ceq.NumValue = AdoRs.Fields[41].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[41].Value);
                        txt_re.NumValue  = AdoRs.Fields[42].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[42].Value);
                        txt_ta.NumValue  = AdoRs.Fields[43].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[43].Value);
                        txt_n.NumValue   = AdoRs.Fields[44].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[44].Value);
                        txt_h.NumValue   = AdoRs.Fields[45].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[45].Value);
                        txt_o.NumValue   = AdoRs.Fields[46].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[46].Value);
                        txt_se.NumValue  = AdoRs.Fields[47].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[47].Value);
                        txt_pcm.NumValue = AdoRs.Fields[48].Value == "" ? 0 : Convert.ToDouble(AdoRs.Fields[48].Value);

                        AdoRs.MoveNext();
                    }

                    comm_slab_test();
                }
            }
            catch (Exception ex)
            {
                if (GeneralCommon.M_CN1.State != 0)
                {
                    GeneralCommon.M_CN1.Close();
                }
                AdoRs = null;
                //RltValue = false;
                GeneralCommon.Gp_MsgBoxDisplay("数据读取失败" + ex.Message, "", "");
            }
        }
Exemplo n.º 29
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (txtConnStr.Text.Trim().Length == 0)
            {
                MessageBox.Show("Connection string cannot be null!");
                return;
            }

            if (btnConnect.Text == "Disconnect")
            {
                EnableGenEntity(false);
                return;
            }

            RefreshConnectionStringAutoComplete();

            DataSet dsTables = null;
            DataSet dsViews  = null;

            if (radioSql.Checked || radioAccess.Checked)
            {
                try
                {
                    if (radioSql.Checked)
                    {
                        Gateway.SetDefaultDatabase(DatabaseType.SqlServer, txtConnStr.Text);
                        if (checkSql2005.Checked)
                        {
                            dsTables = Gateway.Default.SelectDataSet("select [name] from sysobjects where xtype = 'U' and [name] <> 'sysdiagrams' order by [name]", null);
                        }
                        else
                        {
                            dsTables = Gateway.Default.SelectDataSet("select [name] from sysobjects where xtype = 'U' and status > 0 order by [name]", null);
                        }
                        foreach (DataRow row in dsTables.Tables[0].Rows)
                        {
                            tables.Items.Add(row["Name"].ToString());
                        }

                        if (checkSql2005.Checked)
                        {
                            dsViews = Gateway.Default.SelectDataSet("select [name] from sysobjects where xtype = 'V' order by [name]", null);
                        }
                        else
                        {
                            dsViews = Gateway.Default.SelectDataSet("select [name] from sysobjects where xtype = 'V' and status > 0 order by [name]", null);
                        }
                        foreach (DataRow row in dsViews.Tables[0].Rows)
                        {
                            views.Items.Add(row["Name"].ToString());
                        }
                    }
                    else if (radioAccess.Checked)
                    {
                        Gateway.SetDefaultDatabase(DatabaseType.MsAccess, txtConnStr.Text);
                        ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
                        conn.Provider = "Microsoft.Jet.OLEDB.4.0";
                        string connStr = txtConnStr.Text;
                        conn.Open(connStr.Substring(connStr.ToLower().IndexOf("data source") + "data source".Length).Trim('=', ' '), null, null, 0);

                        ADODB.Recordset rsTables = conn.GetType().InvokeMember("OpenSchema", BindingFlags.InvokeMethod, null, conn, new object[] { ADODB.SchemaEnum.adSchemaTables }) as ADODB.Recordset;
                        ADODB.Recordset rsViews  = conn.GetType().InvokeMember("OpenSchema", BindingFlags.InvokeMethod, null, conn, new object[] { ADODB.SchemaEnum.adSchemaViews }) as ADODB.Recordset;

                        while (!rsViews.EOF)
                        {
                            if (!(rsViews.Fields["TABLE_NAME"].Value as string).StartsWith("MSys"))
                            {
                                views.Items.Add(rsViews.Fields["TABLE_NAME"].Value.ToString());
                            }
                            rsViews.MoveNext();
                        }

                        while (!rsTables.EOF)
                        {
                            if (!(rsTables.Fields["TABLE_NAME"].Value as string).StartsWith("MSys"))
                            {
                                bool isView = false;
                                foreach (string item in views.Items)
                                {
                                    if (item.Equals(rsTables.Fields["TABLE_NAME"].Value.ToString()))
                                    {
                                        isView = true;
                                        break;
                                    }
                                }
                                if (!isView)
                                {
                                    tables.Items.Add(rsTables.Fields["TABLE_NAME"].Value.ToString());
                                }
                            }
                            rsTables.MoveNext();
                        }

                        rsTables.Close();
                        rsViews.Close();

                        conn.Close();
                    }

                    EnableGenEntity(true);
                }
                catch (Exception ex)
                {
                    EnableGenEntity(false);
                    MessageBox.Show("Read/write database error!\r\n" + ex.ToString());
                }
            }
            else if (radioOracle.Checked)
            {
                Gateway.SetDefaultDatabase(DatabaseType.Oracle, txtConnStr.Text);

                dsTables = Gateway.Default.SelectDataSet("select * from user_tables where global_stats = 'NO' and (not table_name like '%$%')", null);
                foreach (DataRow row in dsTables.Tables[0].Rows)
                {
                    tables.Items.Add(row["TABLE_NAME"].ToString());
                }

                dsViews = Gateway.Default.SelectDataSet("select * from user_views where (not view_name like '%$%') and (not view_name like 'MVIEW_%') and (not view_name like 'CTX_%') and (not view_name = 'PRODUCT_PRIVS')", null);
                foreach (DataRow row in dsViews.Tables[0].Rows)
                {
                    views.Items.Add(row["VIEW_NAME"].ToString());
                }

                EnableGenEntity(true);
            }
            else if (radioMySql.Checked)
            {
                System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("(^.*database=)([^;]+)(;.*)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                string dbName = r.Replace(txtConnStr.Text, "$2").ToLower();
                Gateway.SetDefaultDatabase(DatabaseType.MySql, r.Replace(txtConnStr.Text, "$1information_schema$3"));

                dsTables = Gateway.Default.SelectDataSet("select * from TABLES where TABLE_TYPE = 'BASE TABLE' and TABLE_SCHEMA = '" + dbName + "'", null);
                foreach (DataRow row in dsTables.Tables[0].Rows)
                {
                    tables.Items.Add(row["TABLE_NAME"].ToString());
                }

                dsViews = Gateway.Default.SelectDataSet("select * from TABLES where TABLE_TYPE = 'VIEW' and TABLE_SCHEMA = '" + dbName + "'", null);
                foreach (DataRow row in dsViews.Tables[0].Rows)
                {
                    views.Items.Add(row["TABLE_NAME"].ToString());
                }

                EnableGenEntity(true);
            }
            else
            {
                EnableGenEntity(false);
                MessageBox.Show("EntityGen tool only supports SqlServer, MsAccess, MySql and Oracle Database!");
            }
        }
Exemplo n.º 30
0
        public string Gf_CarInfFind(string Car_no, string Car_knd, string nameType)
        {
            if (GeneralCommon.M_CN1.State == 0)
            {
                if (!GeneralCommon.GF_DbConnect())
                {
                    return("FAIL");
                }
            }
            string sQuery;
            string Gf_CarInfFind = "";

            switch (nameType)
            {
            case "1":
                //最大装载量
                sQuery = "SELECT H.CAR_WGT_MAX    FROM HP_CAR_IMF H WHERE H.CAR_NO = '" + Car_no + "' AND H.CAR_KND = '" + Car_knd + "' ";
                break;

            case "2":
                //装载量(适量)
                sQuery = "SELECT H.CAR_WGT_AVE    FROM HP_CAR_IMF H WHERE H.CAR_NO = '" + Car_no + "' AND H.CAR_KND = '" + Car_knd + "' ";
                break;

            default:
                //可装车长度
                sQuery = "SELECT H.CAR_LEN        FROM HP_CAR_IMF H WHERE H.CAR_NO = '" + Car_no + "' AND H.CAR_KND = '" + Car_knd + "' ";
                break;
            }
            ADODB.Recordset AdoRs = new ADODB.Recordset();
            try
            {
                AdoRs.Open(sQuery, GeneralCommon.M_CN1, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly);

                if (!AdoRs.BOF && !AdoRs.EOF)
                {
                    //RltValue = true;
                    while (!AdoRs.EOF)
                    {
                        if (AdoRs.Fields[0].Value.ToString() == "")
                        {
                            Gf_CarInfFind = "";
                        }
                        else
                        {
                            Gf_CarInfFind = AdoRs.Fields[0].Value.ToString();
                        }
                        AdoRs.MoveNext();
                    }
                }
                GeneralCommon.M_CN1.Close();
                AdoRs = null;

                return(Gf_CarInfFind);
            }
            catch (Exception ex)
            {
                if (GeneralCommon.M_CN1.State != 0)
                {
                    GeneralCommon.M_CN1.Close();
                }
                AdoRs = null;
                return("");
            }
        }