本文整理汇总了C#中PsqlConnection类的典型用法代码示例。如果您正苦于以下问题:C# PsqlConnection类的具体用法?C# PsqlConnection怎么用?C# PsqlConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsqlConnection类属于命名空间,在下文中一共展示了PsqlConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button2_Click
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;
}
}
示例2: LoadData
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();
}
}
示例3: cmdFinish_Click
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();
}
}
示例4: FetchVersionDetails
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: CalculateCommission
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;
}
示例6: DBLoadRawBatchGrid
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);
}
}
示例7: BusinessUnitTracking_Load
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);
}
示例8: cmdlogin_Click
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 = '" + txtUserName.Text + "'";
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;
}
}
示例9: DBLoadInventoryGrid
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: LoadAssetGrid
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: cmdSaveOutWorkshop_Click
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();
}
示例12: Connect
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");
}
示例13: LoadAccountDetails
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;
}
示例14: cmdDeleteKit_Click
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();
}
示例15: LoadData
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();
}
}