Пример #1
0
        public static string GetDataTable1(string query)
        {
            var            cnn    = ConfigurationManager.AppSettings["PervasiveSQLClient"];
            PsqlConnection DBConn = new PsqlConnection(cnn.ToString());
            PsqlCommand    comm   = new PsqlCommand();

            try
            {
                DBConn.Open();
                comm.Connection  = DBConn;
                comm.CommandText = "Update_Oper";
                comm.CommandType = CommandType.StoredProcedure;
                comm.Parameters.Clear();

                // comm.Parameters.Add()
                comm.Parameters.Add(":id_oper", PsqlDbType.Integer);
                comm.Parameters[comm.Parameters.Count - 1].Value = 1;

                comm.Parameters.Add(":Id_Seccion", PsqlDbType.Integer);
                comm.Parameters[comm.Parameters.Count - 1].Value = 1;

                comm.ExecuteNonQuery();
                return("OK");
            }
            catch (PsqlException ex)
            {
                // Connection failed
                Console.WriteLine(ex.Message);
                return(null);
            }
            finally
            {
                DBConn.Close();
            }
        }
        private PsqlCommand CreateUpdateCommand(PsqlConnection oConnection, POHeader poHeader)
        {
            var commandText = "UPDATE PO_Header" +
                              " SET po_no = @po_no, NewJobNumber = @NewJobNumber," +
                              " activity = @activity, vendor_id = @vendor_id," +
                              " po_type = @po_type, release_date = @release_date," +
                              " cancelled_date = @cancelled_date, payment_amount = @payment_amount," +
                              " subtotal = @subtotal, tax = @tax," +
                              " total = @total, egm_amount = @egm_amount," +
                              " vpo_yes_no = @vpo_yes_no, UserID = @UserID," +
                              " LastModifiedDate = @LastModifiedDate, Community = @Community," +
                              " Product = @Product, Building = @Building," +
                              " Unit = @Unit, taxable_amount = @taxable_amount," +
                              " job_no = @job_no, eSubmittalDate = @eSubmittalDate," +
                              " ApprovePaymentDate = @ApprovePaymentDate, Invoice = @Invoice," +
                              " TaxRate = @TaxRate, eMeasurementPO = @eMeasurementPO," +
                              " SapphirePONumber = @SapphirePONumber, SapphireObjID = @SapphireObjID," +
                              " SapphireObjRID = @SapphireObjRID" +
                              " WHERE SapphireObjID = @SapphireObjID AND SapphireObjRID = @SapphireObjRID ";

            var command = new PsqlCommand
            {
                Connection  = oConnection,
                CommandText = commandText
            };

            CreateCommandParameters(command, poHeader);
            return(command);
        }
        public void LoadData()
        {
            using (PsqlConnection oConn = new PsqlConnection(Connect.sConnStr))
            {
                string sSql = "SELECT * FROM SOLINVENTSS";

                PsqlDataReader rdReader = Connect.getDataCommand(sSql, oConn).ExecuteReader();
                if (rdReader.HasRows)
                {
                    while (rdReader.Read())
                    {
                        int i = dgvSetup.Rows.Add();

                        dgvSetup.Rows[i].Cells["clReceiverRef"].Value = rdReader["sReceiverRef"].ToString().Trim();
                        dgvSetup.Rows[i].Cells["clReceiverAlias"].Value = rdReader["sReceiverAlias"].ToString().Trim();

                        dgvSetup.Rows[i].Cells["clIP"].Value = rdReader["sReceiverIP"].ToString().Trim();
                        dgvSetup.Rows[i].Cells["clSourceRef"].Value = rdReader["sSourceRef"].ToString().Trim();
                        dgvSetup.Rows[i].Cells["clDataPath"].Value = rdReader["sDataPath"].ToString().Trim();
                        dgvSetup.Rows[i].Cells["clSolPMS"].Value = rdReader["sLiquidConn"].ToString().Trim();
                        dgvSetup.Rows[i].Cells["clPastelConn"].Value = rdReader["sPastelConn"].ToString().Trim();

                        dgvSetup.Rows[i].Cells["clSourceStore"].Value = rdReader["sSourceStore"].ToString().Trim();
                        dgvSetup.Rows[i].Cells["clReceiverStore"].Value = rdReader["sReceiverStore"].ToString().Trim();
                    }
                }

                rdReader.Close();
            }
        }
Пример #4
0
        public static void FetchVersionDetails()
        {
            using (PsqlConnection oConn = new PsqlConnection(Connect.sConnStr))
            {
                try
                {
                    oConn.Open();

                }
                catch (Exception Ex)
                {
                    MessageBox.Show("Error connecting to Liquid Database:" + Ex.ToString(),"Connection Error");
                    Application.Exit();
                }

                string sSql = "SELECT * FROM SOLUPD";
                PsqlDataReader rdReader = Connect.getDataCommand(sSql, oConn).ExecuteReader();
                while (rdReader.Read())
                {
                    iCurrVersion = Convert.ToInt32(rdReader["CurrentVersion"].ToString().Trim());
                }

                rdReader.Close();
            }
        }
Пример #5
0
 public static PsqlCommand getDataCommand(string sSQL, PsqlConnection conn)
 {
     try
     {
         if (conn == null)
         {
             try
             {
                 conn = new PsqlConnection(sConnStr);
                 conn.Open();
             }
             catch (PsqlException ex)
             {
                 throw ex;
             }
         }
         else if (conn.State == ConnectionState.Closed)
         {
             conn.Open();
         }
         PsqlCommand cmdSQL = new PsqlCommand(sSQL, conn);
         return(cmdSQL);
     }
     catch
     {
         return(null);
     }
 }
Пример #6
0
        private void loadUserGrid()
        {
            dgUserZoom.Rows.Clear();
            PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr);
            oConn.Open();

            string sSql = "Select * from SOLUS order by UserName";

            PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();

            while (rdReader.Read())
            {
                int n = dgUserZoom.Rows.Add();
                dgUserZoom.Rows[n].Cells["clUserCode"].Value = rdReader["Code"].ToString();
                dgUserZoom.Rows[n].Cells["clDescription"].Value = rdReader["Description"].ToString();
                dgUserZoom.Rows[n].Cells["UserName"].Value = rdReader["UserName"].ToString();
                if (rdReader["UserType"].ToString() == "0")
                    dgUserZoom.Rows[n].Cells["UserType"].Value = "Front Desk";
                if (rdReader["UserType"].ToString() == "1")
                    dgUserZoom.Rows[n].Cells["UserType"].Value = "Administrator";
                if (rdReader["UserType"].ToString() == "2")
                    dgUserZoom.Rows[n].Cells["UserType"].Value = "Asset Maintenance";
                dgUserZoom.Rows[n].Cells["Password"].Value = rdReader["Psswrd"].ToString();
                dgUserZoom.Rows[n].Cells["clCreditInvoice"].Value = rdReader["CreditInvoice"].ToString();
                dgUserZoom.Rows[n].Cells["clCancelReturn"].Value = rdReader["CancelReturnItem"].ToString();
                dgUserZoom.Rows[n].Cells["clCloseOrder"].Value = rdReader["CloseOrder"].ToString();
                dgUserZoom.Rows[n].Cells["clShortName"].Value = rdReader["ShortName"].ToString();
                dgUserZoom.Rows[n].Cells["clTelephoneNumber"].Value = rdReader["TelephoneNumber"].ToString();
                dgUserZoom.Rows[n].Cells["clLockOrder"].Value = rdReader["LockOrder"].ToString();
                dgUserZoom.Rows[n].Cells["clReturnItem"].Value = rdReader["ReturnItem"].ToString();
            }
            rdReader.Close();
            oConn.Dispose();
            dgUserZoom.Focus();
        }
Пример #7
0
        private void LoadData()
        {
            using (PsqlConnection oConn = new PsqlConnection(Connect.sConnStr))
            {
                string sSql = "SELECT * FROM SOLTS";

                PsqlDataReader rdReader = Connect.getDataCommand(sSql, oConn).ExecuteReader();
                if (rdReader.HasRows)
                {
                    while (rdReader.Read())
                    {
                        int i = dgvSetup.Rows.Add();

                        dgvSetup.Rows[i].Cells["Customer_Ref"].Value = rdReader["Customer_Ref"].ToString();

                        dgvSetup.Rows[i].Cells["IP_Destination"].Value = rdReader["IP_Destination"].ToString();
                        dgvSetup.Rows[i].Cells["clAlias"].Value = rdReader["Receiver_Alias"].ToString();
                        dgvSetup.Rows[i].Cells["Supplier_Ref"].Value = rdReader["Supplier_Ref"].ToString();
                        dgvSetup.Rows[i].Cells["Data_Path"].Value = rdReader["sData_Path"].ToString();
                        dgvSetup.Rows[i].Cells["SOLPMS_ConnString"].Value = rdReader["SOLPMS_ConnString"].ToString();

                    }
                }

                rdReader.Close();
            }
        }
        public string ScalarStoredProcADO(string storedProc, Dictionary <string, string> parameters)
        {
            string result;

            using (var oConnection = new PsqlConnection(_pervasiveDbContext))
            {
                var oCommand = new PsqlCommand(storedProc, oConnection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                foreach (var sKey in parameters.Keys)
                {
                    oCommand.Parameters.AddWithValue(sKey, parameters[sKey]);
                }
                var oAdaptor = new PsqlDataAdapter(oCommand);
                var dt       = new DataTable();
                try
                {
                    oConnection.Open();
                    oAdaptor.Fill(dt);
                    oConnection.Close();
                    result = dt.Rows.Count > 0 ? Convert.ToString(dt.Rows[0][0]) : null;
                }
                catch (Exception exception)
                {
                    //_logger.Error($"Database Failure Pervasive ADO.NET {exception}");
                    throw exception;
                }
            }
            return(result);
        }
Пример #9
0
        public void DBLoadInventoryGrid()
        {
            try
            {
                dgvInventory.AutoGenerateColumns = false;
                dgvInventory.DataSource = null;

                string sSql = "";

                using (PsqlConnection pasConn = new PsqlConnection(Connect.sPastelConnStr))
                {
                    pasConn.Open();

                    sSql = "SELECT RTRIM(Category) As Category, RTRIM(ItemCode) As ItemCode, RTRIM(Description) AS Description, RTRIM(UnitSize) AS UnitSize, RTRIM(ICDesc) AS ICDesc";
                    sSql += " FROM Inventory";
                    sSql += " LEFT JOIN InventoryCategory ON ICCode = Category ";

                    dsInventory = Connect.getDataSet(sSql, "Inventory", pasConn);

                    bsInventory = new BindingSource();
                    bsInventory.DataSource = dsInventory;
                    bsInventory.DataMember = dsInventory.Tables["Inventory"].TableName;

                    dgvInventory.DataSource = bsInventory;
                    dgvInventory.ClearSelection();

                    pasConn.Close();
                }

            }
            catch(Exception ex)
            {
                MessageBox.Show("Error Info: " + ex.Message, "Exception Occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #10
0
        private void LoadAssetGrid()
        {
            dgAllAssetZoom.Rows.Clear();
            string sSelectedStoreCode = "All";
            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
            {
                oConn.Open();
                string sSql = "SELECT distinct  Inventory.ItemCode, Description, UserDefText01, UserDefText02, UserDefText03 from Inventory ";
                sSql += " inner join MultiStoreTrn on Inventory.ItemCode = MultiStoreTrn.ItemCode ";
                sSql += " where (StoreCode = '" + sSelectedStoreCode + "' or '" + sSelectedStoreCode + "' = 'All')and (Inventory.ItemCode like '%" + txtItemCodeFilter.Text + "%' or '" + txtItemCodeFilter.Text + "' = '')";
                sSql += " and UserDefNum01 = 1 ";
                //sSql += " and UserDefText01 = 'WORKSHOP'";
                sSql += " order by Inventory.UserDefText01, Inventory.ItemCode ";

                PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
                while (rdReader.Read())
                {
                    int n = dgAllAssetZoom.Rows.Add();
                    dgAllAssetZoom.Rows[n].Cells["clItemCode"].Value = rdReader["ItemCode"].ToString();
                    dgAllAssetZoom.Rows[n].Cells["clDescription"].Value = rdReader["Description"].ToString();
                }
                oConn.Dispose();
                rdReader.Close();
            }
        }
Пример #11
0
        public static Decimal CalculateCommission(string sCommissionType, string sCommissionCategory, Decimal dInvoiceValue)
        {
            decimal dTotalCommission = 0;
            decimal dCategory = 0;
            decimal dCommissionType = 0;
            //get category percentage
            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                String sSql = "Select CategoryPercentage from SOLMARKCAT where CategoryName = '" + sCommissionCategory + "'";
                string sPercentage = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteScalar().ToString();
                dCategory = Convert.ToDecimal(sPercentage) / 100;

                try
                {
                    sSql = "Select CommissionPercentage From SOLMARKCOMTIPE where CommissionTipe = '" + sCommissionType + "'";
                    string sComPercentage = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteScalar().ToString();
                    dCommissionType = Convert.ToDecimal(sComPercentage) / 100;
                }
                catch
                {
                    dCommissionType = 1;
                }

                oConn.Dispose();
            }
            dTotalCommission = dInvoiceValue * dCategory * dCommissionType;

            return dTotalCommission;
        }
Пример #12
0
        private void BusinessUnitTracking_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            this.ControlBox = false;
            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                string sSql = "select UnitId, concat(concat(UnitName,' - '),UnitDescription) 'Name'  from SOLMBS order by UnitID";
                DataSet dsUnits = Solsage_Process_Management_System.Classes.Connect.getDataSet(sSql, "Unit", oConn);
                selUnits.DataSource = dsUnits.Tables["Unit"];
                selUnits.DisplayMember = "Name";
                this.txtUnitID.DataBindings.Add(new Binding("Text", dsUnits.Tables["Unit"], "UnitID", true));
                if (loadOperators(oConn))
                {
                    selOperators_SelectedIndexChanged(sender, e);
                    viewSheet(oConn);
                }
                oConn.Dispose();
            }
            DataGridViewCellStyle dgCellStyle = new DataGridViewCellStyle();
            dgCellStyle.BackColor = Color.LightGray;
            dgInput.Columns[0].DefaultCellStyle = dgCellStyle;
            dgInput.Columns[1].DefaultCellStyle = dgCellStyle;
            dgInput.Columns[2].DefaultCellStyle = dgCellStyle;
            dgInput.Columns["cl24"].DefaultCellStyle = dgCellStyle;
            dgInput.Columns["clEntryId"].Width = 0;

            this.txtUnitID.TextChanged += new System.EventHandler(this.txtUnitID_TextChanged);
            this.selOperators.SelectedIndexChanged += new System.EventHandler(this.selOperators_SelectedIndexChanged);
        }
Пример #13
0
        private void cmdlogin_Click(object sender, EventArgs e)
        {
            bool bMatch = false;

            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                string sSql = "Select UserName,Psswrd,Code,UserType from SOLUS where UserName = '******'";
                PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
                while (rdReader.Read())
                {
                    if (txtPassword.Text == rdReader["Psswrd"].ToString().Trim())
                    {
                        bMatch = true;
                        sUserCode = rdReader["Code"].ToString().Trim();
                    }
                }
                rdReader.Close();
                oConn.Dispose();
            }

             if (bMatch == true)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Username and Password does not match.  Please try again.");
                cmdClearFields();
                this.ActiveControl = txtUserName;
            }
        }
Пример #14
0
        private void cmdFinish_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("This will add selected stock to store. Continue?", "Recieve Stock", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
                {
                    oConn.Open();

                    foreach (DataGridViewRow dgRow in dgReciveOldStock.Rows)
                    {

                        string sSql = "Insert into SOLMSM ";
                        sSql += "(GeneralItemCode,GenItemDescription,QuantityScanned,UserName,ItemDate)";
                        sSql += "Values ('" + dgRow.Cells["clItemCode"].Value.ToString().Trim() + "','" + dgRow.Cells["clItemDescription"].Value.ToString().Trim() + "','" + dgRow.Cells["clQuantity"].Value.ToString().Trim() + "', '" + Solsage_Process_Management_System.Classes.Global.sLogedInUserName.ToString() + "', '" + lblDateTime.Text + "')";
                        int iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();

                        sSql = "Insert into SOLMROS ";
                        sSql += "(ItemCode,ItemDescription,Quantity,UserName,Date)";
                        sSql += "Values ('" + dgRow.Cells["clItemCode"].Value.ToString().Trim() + "','" + dgRow.Cells["clItemDescription"].Value.ToString().Trim() + "','" + dgRow.Cells["clQuantity"].Value.ToString().Trim() + "', '" + Solsage_Process_Management_System.Classes.Global.sLogedInUserName.ToString() + "', '" + lblDateTime.Text + "') ";
                        iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();

                    }

                    oConn.Dispose();
                }
                this.Close();
            }
        }
Пример #15
0
 public void Connect(string password)
 {
     _sb.Password = password;
     Connection   = new PsqlConnection(_sb.ToString());
     Connection.Open();
     LoadDbList();
 }
Пример #16
0
        private void cmdDeleteKit_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("This will permanently delete the current selected Kit Items. Are you sure?", "Delete Kit Items", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            {
                using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
                {
                    oConn.Open();
                    foreach (DataGridViewRow dgRow in dgKitMain.Rows)
                    {
                        // Main Kit code
                        if (dgRow.Cells[0].Value != null)
                        {
                            string sDelSql = "delete From SOLKIT where KitName = '" + txtKitName.Text.Trim() + "'";
                            int delRet = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sDelSql, oConn).ExecuteNonQuery();

                            //Kit Details
                            string sDelSql2 = "delete From SOLKITDET where FkMainItemCode = '" + dgRow.Cells["clMainItemCode"].Value.ToString() + "'";
                            int delRet2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sDelSql2, oConn).ExecuteNonQuery();
                        }
                    }
                    oConn.Dispose();
                }
                dgKitDetails.Rows.Clear();
                dgKitMain.Rows.Clear();
                txtKitName.Text = "";
            }
            dgKitDetails.Rows.Add();
            dgKitMain.Rows.Add();
        }
Пример #17
0
        public static DataTable GetDataTable(string query)
        {
            var            cnn    = ConfigurationManager.AppSettings["PervasiveSQLClient"];
            PsqlConnection DBConn = new PsqlConnection(cnn.ToString());

            try
            {
                DataTable dt = new DataTable();
                // Open the connection
                DBConn.Open();
                PsqlDataAdapter da = new PsqlDataAdapter();
                da.SelectCommand = new PsqlCommand(query, DBConn);
                da.Fill(dt);
                //Console.WriteLine("Connection Successful!");

                return(dt);
            }
            catch (PsqlException ex)
            {
                // Connection failed
                Console.WriteLine(ex.Message);
                return(null);
            }
            finally
            {
                DBConn.Close();
            }
        }
Пример #18
0
 public void Connect(string dsn, string host)
 {
     Console.Error.Write("Connecting to {0}...", host);
     DBConn = new PsqlConnection(string.Format("Server DSN={0}; Host={1}", dsn, host));
     DBConn.Open();
     Console.Error.WriteLine("connected");
 }
Пример #19
0
        private void button2_Click(object sender, EventArgs e)
        {
            string sConnString = "Server Name=localhost;Database Name=LSYNC;";
            using (PsqlConnection oPastelConn = new PsqlConnection(sConnString))
            {
                oPastelConn.Open();

                Cursor = System.Windows.Forms.Cursors.WaitCursor;
                solPastelSDK clsPastelSDK = new solPastelSDK();

                string[] aLines = new string[2];
                aLines[0] = "0|1|105.28|120|DAY |1|0|0|023PHIREDRILL|DRILL HILTI TE16                        |4|001|     |";
              //              aLines[0] = "0|1|162.28|162.28|DAY |0|0|0|039PHIREGENERA|6KVA GENERATOR HONDA MGS6000            |4|001|     |";
                aLines[1] = "0|1|0.02|0.02|    |0|0|0|1000020        |Rounding                                |6|001|     |";

                string sHeader = "|||ABS001|05/02/2010|IN100159|Y|0|||||||||00001|0||2010/02/05 12:00:00 AM||Blondie||1|||||||||26477506|0";

                string sDataPath = "C:\\Pastel09\\FAIREGLEN";
                string sResult = clsPastelSDK.CreatePastelDocument(sHeader, aLines, 106, sDataPath, Global.iPastelSdkUser, false, oPastelConn, 1);

                MessageBox.Show(sResult);
                //CreatePastelDocument(sHeader, aLines, 106, sDataPath, Global.iPastelSdkUser, Global.bLogCreateDocument);

                //txtSdkResults.Text = sResult;

                Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
Пример #20
0
        private string DBFetchSIRange()
        {
            string sSql = "";
            string sSIRange = "(";

            using (PsqlConnection liqConn = new PsqlConnection(Connect.sConnStr))
            {
                liqConn.Open();

                sSql = "SELECT DocNumber FROM SOLSIL";
                sSql += " WHERE BatchNumber LIKE '%" + txtInclBatch.Text + "%'";

                PsqlDataReader rdReader = Connect.getDataCommand(sSql, liqConn).ExecuteReader();

                if (rdReader.HasRows)
                {
                    while (rdReader.Read())
                    {
                        sSIRange += "'" + rdReader["DocNumber"].ToString().Trim() + "',";
                    }

                    rdReader.Close();
                }

                liqConn.Close();
            }

            sSIRange = sSIRange.Substring(0, sSIRange.Length - 1);
            sSIRange += ")";

            return sSIRange;
        }
Пример #21
0
        private void cmdSaveOutWorkshop_Click(object sender, EventArgs e)
        {
            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
            {
                oConn.Open();
                for (int i = 0; i < dgTakeOutWorkshop.Rows.Count; i++)
                {
                    if (dgTakeOutWorkshop.Rows[i].Cells["chkSelectOut"].Value == chkSelectOut.TrueValue)
                    {

                        string sSql = "Update Inventory Set ";
                        sSql += "UserDefText01 = '',";
                        sSql += "UserDefText03 = '',";
                        sSql += "UserDefText02 = '' ";
                        sSql += "where ItemCode = '" + this.dgTakeOutWorkshop.Rows[i].Cells[0].Value + "'";

                        int iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
                        if (iReturn <= 0)
                        {
                            MessageBox.Show("An error occured with the movement of item " + this.dgTakeOutWorkshop.Rows[i].Cells[0].Value + " to the workshop");

                        }

                    }
                }

                cmdSaveOutWorkshop.Enabled = false;
                oConn.Dispose();
            }
            dgPutInWorkshop.Rows.Clear();
            currentlyOutWorkshopGridLoad();

            dgTakeOutWorkshop.Rows.Clear();
            currentlyInWorkshopGridLoad();
        }
        private void LoadAccountDetails()
        {
            Cursor = System.Windows.Forms.Cursors.WaitCursor;
            dgAccountDetails.Rows.Clear();

            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                String sSql = "Select Category, CommissionType, InvoiceValue, CustomerCode, DocumentNumber From SOLMARKTRANS where MarketerCode = '" + txtMarketer.Text.Trim() + "' order by CustomerCode";
                PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
                while (rdReader.Read())
                {
                    int n = dgAccountDetails.Rows.Add();
                    dgAccountDetails.Rows[n].Cells["clCustomerCode"].Value = rdReader[3].ToString();
                    dgAccountDetails.Rows[n].Cells["clDocumentNumber"].Value = rdReader[4].ToString();
                    dgAccountDetails.Rows[n].Cells["clCategory"].Value = rdReader[0].ToString();
                    dgAccountDetails.Rows[n].Cells["clCommissionType"].Value = rdReader[1].ToString();
                    dgAccountDetails.Rows[n].Cells["clInvoiceValue"].Value = rdReader[2].ToString();
                    dgAccountDetails.Rows[n].Cells["clCommissionAmount"].Value = Classes.Functions.CalculateCommission(rdReader[1].ToString(), rdReader[0].ToString(), Convert.ToDecimal(rdReader[2].ToString())).ToString("N2");

                }
                rdReader.Dispose();
                oConn.Dispose();
            }
            AddTotals();
            Cursor = System.Windows.Forms.Cursors.Default;
        }
Пример #23
0
        private void DBLoadRawBatchGrid()
        {
            try
            {
                dgvRawBatches.AutoGenerateColumns = false;
                dgvRawBatches.DataSource = null;

                string sSql = "";

                using (PsqlConnection liqConn = new PsqlConnection(Connect.sConnStr))
                {
                    liqConn.Open();

                    sSql = "SELECT * FROM SOLSIL";
                    sSql += " WHERE DocNumber = '" +sDocNumFilter + "'" ;

                    dsRawBatchInfo = Connect.getDataSet(sSql, "RawBatch", liqConn);

                    bsRawBatch = new BindingSource();
                    bsRawBatch.DataSource = dsRawBatchInfo;
                    bsRawBatch.DataMember = dsRawBatchInfo.Tables["RawBatch"].TableName;

                    dgvRawBatches.DataSource = bsRawBatch;

                    liqConn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Info: " + ex.Message, "Exception Occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #24
0
 public void Connect(string userId, string password)
 {
     _sb.UserID   = "";
     _sb.Password = "";
     Connection   = new PsqlConnection(_sb.ToString());
     Connection.Open();
     LoadDbList();
 }
Пример #25
0
        private void cmdlogin_Click(object sender, EventArgs e)
        {
            bool bMatch = false;
            string sUserName = "";
            string sUserCode = "";
            string sUserType = "";

            if (txtUserName.Text == "")
            {
                MessageBox.Show("Please supply username field");
                return;
            }
            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                string sSql = "Select UserName,Psswrd,Code,UserType, CreditInvoice from SOLUS where UserName = '******'";
                PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
                while (rdReader.Read())
                {
                    if (txtPassword.Text == rdReader["Psswrd"].ToString().Trim())
                    {
                        bMatch = true;
                        sUserName = rdReader["UserName"].ToString().Trim();
                        sUserCode = rdReader["Code"].ToString().Trim();
                        sUserType = rdReader["UserType"].ToString().Trim();
                        Global.iCreditInvoice = Convert.ToInt32(rdReader["CreditInvoice"]);
                    }
                }

                rdReader.Close();
                oConn.Dispose();
            }

            if (bMatch == true)
            {

                this.Visible = false;
                Cursor = System.Windows.Forms.Cursors.WaitCursor;
                Main frmMain = new Solsage_Process_Management_System.Main();

                Global.sLogedInUserName = sUserName;
                Global.sLogedInUserCode = sUserCode;
                Global.sLogedInUserType = sUserType;
                Global.frmLogin = this;

                Global.bUseBackground = chkUseBackground.Checked;

                Global.frmMain = frmMain;
                frmMain.Show();

                Cursor = System.Windows.Forms.Cursors.Default;
            }
            else
            {
                MessageBox.Show("Login Failed");
                cmdClearFields();
            }
        }
Пример #26
0
        public bool CheckIfClientExists(Client client)
        {
            using (PsqlConnection pastelConnection = new PsqlConnection(Connect.sPastelConnStr))
            {
                string sqlPastel = String.Format("SELECT COUNT(*) FROM CustomerMaster WHERE CustomerMaster.CustomerCode = '{0}'", client.UserName);
                int    count     = (int)Connect.getDataCommand(sqlPastel, pastelConnection).ExecuteScalar();

                return(count > 0);
            }
        }
Пример #27
0
        public static DataSet getDataSet(string sSQL, string sTable, PsqlConnection conn)
        {
            DataSet ds = new DataSet();

            // create a data adapter
            PsqlDataAdapter da = new PsqlDataAdapter(sSQL, conn);

            da.Fill(ds, sTable);
            return (ds);
        }
Пример #28
0
        public PsqlServerInstance(PsqlConnection connection)
        {
            _sb = new PsqlConnectionStringBuilder(connection.ConnectionString);
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }

            Connection = connection;
        }
    static void Main()
    {
        try
        {
            string textFile = fileName;
            Console.WriteLine("Loading File: " + textFile);
            conn = new PsqlConnection(@"ServerDSN=DEMODATA");
            conn.Open();
            cmd             = new PsqlCommand();
            cmd.Connection  = conn;
            cmd.CommandText = @"create table texttable(textfile varchar(255),textdata longvarchar)";
            //cmd.ExecuteNonQuery();

            cmd.CommandText = @"insert into texttable values (?,?)";
            cmd.Parameters.Add("@textfile", PsqlDbType.VarChar, 30);
            cmd.Parameters.Add("@textdata", PsqlDbType.LongVarChar, 1000000);

            Console.WriteLine("Loading File: " + textFile);

            FileStream   fs1      = new FileStream(textFile, FileMode.Open, FileAccess.Read);
            StreamReader sr1      = new StreamReader(fs1);
            string       textData = "";
            textData = sr1.ReadToEnd();

            Console.WriteLine("TextBytes has length {0} bytes.", textData.Length);

            //string textData = GetTextFile(textFile);
            cmd.Parameters["@textfile"].Value = textFile;
            cmd.Parameters["@textdata"].Value = textData;

            cmd.CommandText = cmd.CommandText;
            cmd.ExecuteNonQuery();

            Console.WriteLine("Loaded {0} into texttable.", fileName);

            cmd.CommandText = "select * from texttable";
            PsqlDataReader dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                dr.Read();
                textFile = @"Output.txt";
                StreamWriter sw = new StreamWriter(textFile);
                sw.Write(dr[1].ToString());
                Console.WriteLine("TextFile: {0}.\nTextData written to {1}", dr[0].ToString(), textFile);
            }
        }
        catch (PsqlException ex)
        {
            Console.WriteLine(ex.ToString());
        }
        finally
        {
            conn.Close();
        }
    }
Пример #30
0
        private void cmdReNumber_Click(object sender, EventArgs e)
        {
            int iNextDocNum = 1;
            string sOutput = "";
            using (PsqlConnection PoConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
            {
                PoConn.Open();
                using (PsqlConnection LoConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
                {
                    LoConn.Open();

                    foreach (DataGridViewRow oRow in dgRenumberDocs.Rows)
                    {
                        string sNewDocNum = iNextDocNum.ToString("00000000");

                        //UPDATE HISTORY HEADER
                        string sSql = "update HistoryHeader set DocumentNumber = '" + sNewDocNum + "' ";
                        sSql += "where DocumentNumber = '" + oRow.Cells["clDocumentNumber"].Value.ToString() + "' ";
                        int iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, PoConn).ExecuteNonQuery();

                        //UPDATE HISTORY LINES
                        sSql = "update HistoryLines set DocumentNumber = '" + sNewDocNum + "' ";
                        sSql += "where DocumentNumber = '" + oRow.Cells["clDocumentNumber"].Value.ToString() + "' ";
                        iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, PoConn).ExecuteNonQuery();

                        sOutput += oRow.Cells["clDocumentNumber"].Value.ToString() + ", " + sNewDocNum + "\r\n";

                        //UPDATE SOLHH
                        sSql = "update SOLHH set DocNumber = '" + sNewDocNum + "' ";
                        sSql += "where DocNumber = '" + oRow.Cells["clDocumentNumber"].Value.ToString() + "' ";
                        iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, LoConn).ExecuteNonQuery();

                        //UPDATE SOLHL
                        sSql = "update SOLHL set Header = '" + sNewDocNum + "' ";
                        sSql += "where Header = '" + oRow.Cells["clDocumentNumber"].Value.ToString() + "' ";
                        iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, LoConn).ExecuteNonQuery();

                        iNextDocNum++;
                    }

                    string sFinalPath = "C:\\Pastel09\\ReNumberLog.txt";

                    using (FileStream fs = File.Create(sFinalPath))
                    {
                        byte[] info = new UTF8Encoding(true).GetBytes(sOutput);
                        fs.Write(info, 0, info.Length);
                        fs.Close();
                    }

                    LoConn.Dispose();
                }
                PoConn.Dispose();
            }
        }
Пример #31
0
 private void BuildDataset()
 {
     dsEstimatedTurnover = new DataSet();
     using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
     {
         string sSql = "Select CustomerCode,CustomerDesc, LinkWeb as Balance ";
         sSql += " from CustomerMaster";
         dsEstimatedTurnover = Solsage_Process_Management_System.Classes.Connect.getDataSet(sSql, "dtEstimatedTurnover", oConn);
         oConn.Dispose();
     }
 }
Пример #32
0
        public void LoadErrorInfo()
        {
            using (PsqlConnection oConn = new PsqlConnection(Connect.sConnStr))
            {
                int iDgvRowCount = 0;
                int iErrorCounter = 1;
                string sSql = "SELECT * FROM SOLTERR ORDER BY dtTimeFailed DESC ";

                PsqlDataReader rdReader = Connect.getDataCommand(sSql, oConn).ExecuteReader();

                if (rdReader.HasRows)
                {
                    btnMarkAsHandled.Enabled = true;
                    while (rdReader.Read())
                    {
                        iDgvRowCount = dgvTransferErrors.Rows.Add();

                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clErrorID"].Value = rdReader["sTransferErrorID"].ToString().Trim();
                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clSourceDocNum"].Value = rdReader["sDocNum"].ToString().Trim();
                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clReceiverIP"].Value = rdReader["sTransToIP"].ToString().Trim();
                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clReceiverDatapath"].Value = rdReader["sTransToDataPath"].ToString().Trim();
                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clDateTimeFailed"].Value = rdReader["dtTimeFailed"];
                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clUserCode"].Value = rdReader["sUserCode"].ToString().Trim();
                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clUserName"].Value = rdReader["sUserName"].ToString().Trim();
                        dgvTransferErrors.Rows[iDgvRowCount].Cells["clErrorString"].Value = rdReader["sErrorInfo"].ToString().Trim();

                        if (rdReader["iHandled"].ToString().Trim() == "1")
                            dgvTransferErrors.Rows[iDgvRowCount].DefaultCellStyle.BackColor = Color.Blue;
                        else
                            dgvTransferErrors.Rows[iDgvRowCount].DefaultCellStyle.BackColor = Color.White;

                        if (!bActive)
                        {
                            if(rdReader["sDocNum"].ToString().Trim() == sActiveError)
                            {
                                dgvTransferErrors.Rows[iDgvRowCount].Selected = true;
                                iErrorCounter = iDgvRowCount;
                                bActive = true;
                            }
                        }
                    }

                    if (iErrorCounter != 1)
                    {
                        dgvTransferErrors.Rows[iErrorCounter].Selected = true;
                    }

                    SetDetailedInformation();
                }

                rdReader.Close();

            }
        }
Пример #33
0
 private void LoadChecklistDetail()
 {
     string sSql = "Select * From SOLWC where ChecklistName = '" + txtChecklistName.Text.Trim() + "'";
     using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
     {
         PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
         while (rdReader.Read())
         {
             txtChecklistDescription.Text = rdReader["ChecklistDescription"].ToString();
         }
     }
 }
Пример #34
0
 private void executeLiquidQuery(PsqlConnection liquidConnection, string sqlLiquid)
 {
     try
     {
         Connect.getDataCommand(sqlLiquid, liquidConnection).ExecuteNonQuery();
         _log.Debug(String.Format("Successfully executed query '{0}'", sqlLiquid));
     }
     catch (Exception ex)
     {
         _log.Error(String.Format("Could not execute liquid query '{0}'", sqlLiquid), ex);
     }
 }
Пример #35
0
        private void btnSaveRule_Click(object sender, EventArgs e)
        {
            if (txtRuleUnit.Text == "")
            {
                MessageBox.Show("Please Fill In New Unit Name");
                return;
            }
            if (txtRuleDesc.Text == "")
            {
                MessageBox.Show("Please Fill In New Unit Description");
                return;
            }

            if (txtNetMass.Text == "")
            {
                MessageBox.Show("Please Fill In New Unit Net Mass");
                return;
            }

            string sCat = selCategory.SelectedItem.ToString().Substring(0, 3);

            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                if (txtUnitId.Text == "")//new item
                {
                    string sSql = "Insert into SOLMS (fkInventoryCategory, sUnit, sUnitNotes, dNetMass) VALUES ";
                    sSql += "(";
                    sSql += "'" + sCat.Trim() + "'";
                    sSql += ",'" + txtRuleUnit.Text + "'";
                    sSql += ",'" + txtRuleDesc.Text + "'";
                    sSql += ",'" + txtNetMass.Text + "'";
                    sSql += ")";
                    int iRet = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
                    sSql = "SELECT @@IDENTITY FROM SOLMS";
                    txtUnitId.Text = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteScalar().ToString();
                }
                else
                {
                    string sSql = "Update SOLMS set ";
                    sSql += " sUnit  = '" + txtRuleUnit.Text + "'";
                    sSql += ", sUnitNotes = '" + txtRuleDesc.Text + "'";
                    sSql += ", dNetMass = '" + txtNetMass.Text + "'";
                    sSql += " where id = " + txtUnitId.Text;

                    int iRet = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
                }

            }

            loaddgvUnits();
            btnSaveRule.Enabled = true;
        }
Пример #36
0
 private void executePastelQuery(PsqlConnection pastelConnection, string sqlPastel)
 {
     try
     {
         Connect.getDataCommand(sqlPastel, pastelConnection).ExecuteNonQuery();
         _log.Debug(String.Format("Successfully executed query '{0}'", sqlPastel));
     }
     catch (Exception ex)
     {
         _log.Error(String.Format("Could not execute pastel query '{0}'", sqlPastel), ex);
     }
 }
Пример #37
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                string delSql = "delete From SOLMARKDET where MarketerCode = '" + txtName.Text.Trim().Replace("'", "''") + "'";
                int delRet = Solsage_Process_Management_System.Classes.Connect.getDataCommand(delSql, oConn).ExecuteNonQuery();

                oConn.Dispose();
            }
            cmdNew_Click(null, null);
        }
        public string ScalarQueryStringADO(string queryString)
        {
            var result = "";

            using (var oConnection = new PsqlConnection(_pervasiveDbContext))
            {
                oConnection.Open();
                var oCommand = new PsqlCommand(queryString, oConnection);
                result = Convert.ToString(oCommand.ExecuteScalar());
                oConnection.Close();
            }
            return(result);
        }
Пример #39
0
        public void LoadRulePropertiesDGV(string sRuleID)
        {
            using (PsqlConnection oConn = new PsqlConnection(Connect.sConnStr))
            {
                string sLoadSql = "SELECT * FROM SOLRP WHERE FKiRuleID = '" + sRuleID + "'";

                PsqlDataReader rdReader = Connect.getDataCommand(sLoadSql, oConn).ExecuteReader();

                while (rdReader.Read())
                {
                    dgvRuleParameters.Rows.Add(rdReader["iBeginVal"].ToString(), "", rdReader["iEndVal"].ToString(), rdReader["dCalcPercentage"].ToString(), rdReader["PKiRParameterID"].ToString(), rdReader["dReturnCalcPercentag"].ToString());
                }
            }
        }
Пример #40
0
 private void cmdDeleteLiquidOpenOrders_Click(object sender, EventArgs e)
 {
     if (lblLiquidClosedOrders.Text != "0")
     {
         using (PsqlConnection oConn = new PsqlConnection(Connect.sConnStr))
         {
             string sSql = "DELETE FROM SOLHL WHERE Header in (" + GetOpenDocuments() + ")";
             int iRet = Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
             sSql = "DELETE FROM SOLHH WHERE Status = 3";
             iRet = Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
         }
     }
     lblLiquidClosedOrders.Text = "0";
 }
Пример #41
0
        private void lbBlockedItems_DoubleClick(object sender, EventArgs e)
        {
            lbActiveItems.Items.Add(lbBlockedItems.SelectedItem);

            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                //insert item into SOLIM
                string sSql = "Delete from SOLIM where ItemCode = '" + lbBlockedItems.SelectedItem.ToString().Trim() + "'";
                int iRet2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
                oConn.Dispose();
            }
            lbBlockedItems.Items.Remove(lbBlockedItems.SelectedItem);
        }
Пример #42
0
        private void cmdReturn_Click(object sender, EventArgs e)
        {
            string[] aPastelUpdateLine = new string[0];
            using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
            {
                oConn.Open();
                for (int i = 0; i < dgItemGrid.Rows.Count; i++)
                {
                    if (dgItemGrid.Rows[i].Cells["clSelect"].Value == clSelect.TrueValue)
                    {
                        string sSql = "Update SOLAL set status = 1, UserCodeReturn = '" + txtSalesCode.Text + "' ";
                        sSql += "where DocumentNumber = '" + dgItemGrid.Rows[i].Cells["clDocNumber"].Value + "' ";
                        sSql += "and AssetNumber = '" + txtAssetCode.Text.Trim() + "' ";
                        sSql += "and ItemCode = '" + dgItemGrid.Rows[i].Cells["clItemCode"].Value + "' ";

                        int iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
                        if (iReturn == 0)
                        {
                            MessageBox.Show("An erros occured during the update of SOLAL", "SOLAL Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }

                    Array.Resize<string>(ref aPastelUpdateLine, aPastelUpdateLine.Length + 1);
                    aPastelUpdateLine[aPastelUpdateLine.Length - 1] = dgItemGrid.Rows[i].Cells["clItemCode"].Value.ToString();

                }

                oConn.Dispose();
            }

            if (aPastelUpdateLine.Length > 0)
            {
                using (PsqlConnection oConnPastel = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
                {
                    oConnPastel.Open();
                    for (int i = 0; i < aPastelUpdateLine.Length; i++)
                    {
                        string sSql = "Update Inventory set ";
                        sSql += "UserDefText01 = '' ";
                        sSql += ",UserDefText02 = '' ";
                        sSql += "where ItemCode = '" + aPastelUpdateLine[0].ToString().Trim() + "'";

                        int iReturn = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConnPastel).ExecuteNonQuery();
                    }
                    oConnPastel.Dispose();
                }
            }

            LoadAssetGrid();
        }
Пример #43
0
 private void LoadKitGrid()
 {
     dgKitZoom.Rows.Clear();
     using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
     {
         String sSql = "Select KitName From SOLKIT where KitName like '%" + txtKitName.Text.Trim() + "%' group by KitName";
         PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
         while (rdReader.Read())
         {
             int n = dgKitZoom.Rows.Add();
             dgKitZoom.Rows[n].Cells["clKitName"].Value = rdReader["KitName"].ToString();
         }
     }
 }
Пример #44
0
        public void CreateClient(Client newClient)
        {
            using (PsqlConnection pastelConnection = new PsqlConnection(Connect.sPastelConnStr))
            {
                string sqlPastel = createCustomerMasterSQL(newClient);
                executePastelQuery(pastelConnection, sqlPastel);
            }

            using (PsqlConnection liquidConnection = new PsqlConnection(Connect.sConnStr))
            {
                var sqlLiquid = createLiquidCNSQL(newClient);
                executeLiquidQuery(liquidConnection, sqlLiquid);
            }
        }
 private void UpdatePo(POHeader poHeader)
 {
     try
     {
         var connString = ConfigurationManager.ConnectionStrings["ADONET35"].ToString();
         using (var oConnection = new PsqlConnection(connString))
         {
             oConnection.Open();
             var insertCommand = CreateInsertStatement(oConnection, poHeader);
             insertCommand.ExecuteNonQuery();
             oConnection.Close();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void NonQueryPervasiveADO(string queryString)
 {
     try
     {
         using (var oConnection = new PsqlConnection(_pervasiveDbContext))
         {
             oConnection.Open();
             var oCommand = new PsqlCommand(queryString, oConnection);
             oCommand.ExecuteNonQuery();
             oConnection.Close();
         }
     }
     catch (Exception exception)
     {
         //_logger.Error($"Database Failure Pervasive ADO.NET {queryString} {exception.InnerException}");
         throw exception;
     }
 }
        public void LoadCadastro()
        {
            PsqlConnection psqlConnection = new PsqlConnection(Connection);

            try
            {
                psqlConnection.Open();

                PsqlCommand command = new PsqlCommand();
                string      sql     = "select codigobtr as Codigo, razsoc as Razao, cnpjcpf as CNPJ, inscest as IE from prg_empresa_btr order by codigobtr";
                command.CommandText = sql;
                command.Connection  = psqlConnection;
                PsqlDataAdapter adapter = new PsqlDataAdapter(command);
                DataSet         dataSet = new DataSet("Prosoft");
                adapter.Fill(dataSet, "Empresas");
                Empresas = new List <Empresas>();
                foreach (DataRow row in dataSet.Tables["Empresas"].Rows)
                {
                    Empresas.Add(new Empresas
                    {
                        Codigo = ((string)row.ItemArray[0]).TrimEnd(),
                        Razao  = ((string)row.ItemArray[1]).TrimEnd(),
                        CNPJ   = ((string)row.ItemArray[2]).TrimEnd(),
                        IE     = ((string)row.ItemArray[3]).TrimEnd()
                    });
                }

                psqlConnection.Close();
            }
            catch (PsqlException ex)
            {
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (psqlConnection.State == System.Data.ConnectionState.Open)
                {
                    psqlConnection.Close();
                }
            }
        }
        private PsqlCommand CreateInsertStatement(PsqlConnection oConnection, POHeader poHeader)
        {
            var commandText = "INSERT INTO PO_Header (po_no, NewJobNumber, activity, vendor_id, po_type, release_date, cancelled_date, payment_amount," +
                              "subtotal, tax, total, egm_amount, vpo_yes_no, UserID, LastModifiedDate, Community, Product, Building, Unit," +
                              "taxable_amount, job_no, eSubmittalDate, ApprovePaymentDate, Invoice, TaxRate, eMeasurementPO, SapphirePONumber, SapphireObjID," +
                              "SapphireObjRID)" +
                              "VALUES (@po_no,@NewJobNumber, @activity, @vendor_id, @po_type, @release_date, @cancelled_date, @payment_amount,@subtotal, @tax," +
                              "@total, @egm_amount,@vpo_yes_no, @UserID, @LastModifiedDate, @Community,@Product, @Building,@Unit, @taxable_amount," +
                              "@job_no, @eSubmittalDate, @ApprovePaymentDate, @Invoice,@TaxRate, @eMeasurementPO, @SapphirePONumber, @SapphireObjID, @SapphireObjRID)";

            var command = new PsqlCommand
            {
                Connection  = oConnection,
                CommandText = commandText
            };

            CreateCommandParameters(command, poHeader);
            return(command);
        }
        public DataTable QueryPervasiveADO(string queryString)
        {
            var dataTable = new DataTable();

            try
            {
                using (var oConnection = new PsqlConnection(_pervasiveDbContext))
                {
                    oConnection.Open();
                    var oCommand = new PsqlCommand(queryString, oConnection);
                    var oAdapter = new PsqlDataAdapter(oCommand);
                    oAdapter.Fill(dataTable);
                }
            }
            catch (Exception exception)
            {
                //_logger.Error($"Database Failure Pervasive ADO.NET {exception.InnerException}");
                return(null);
            }

            return(dataTable);
        }
        public void StoredProcADO(string storedProc, Dictionary <string, string> parameters)
        {
            using (PsqlConnection oConnection = new PsqlConnection(_pervasiveDbContext))
            {
                PsqlCommand oCommand = new PsqlCommand(storedProc, oConnection);
                oCommand.CommandType = CommandType.StoredProcedure;
                foreach (String sKey in parameters.Keys)
                {
                    oCommand.Parameters.AddWithValue(sKey, parameters[sKey]);
                }

                try
                {
                    oConnection.Open();
                    oCommand.ExecuteNonQuery();
                }
                catch (PsqlException pSqlException)
                {
                    //_logger.Error($"Database Failure Pervasive ADO.NET {pSqlException}");
                    throw pSqlException;
                }
            }
        }