本文整理匯總了C#中System.Windows.Forms.ProgressBar.Increment方法的典型用法代碼示例。如果您正苦於以下問題:C# ProgressBar.Increment方法的具體用法?C# ProgressBar.Increment怎麽用?C# ProgressBar.Increment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.Increment方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetFiltered
// bardzo wolny filtr kolorow (nasycenie poszczegolnych składowych)
//!: znowu unsafe i iteracje po wskaznikach by się chyba przydały
public static Bitmap GetFiltered(Bitmap bmp,Color c, ProgressBar pb = null)
{
float r,g,b;
for(int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
Color get = bmp.GetPixel(x, y);
r = (c.R > 0) ? (float)get.R * ((float)c.R / 255) : 0;
g = (c.G > 0) ? (float)get.G * ((float)c.G / 255) : 0;
b = (c.B > 0) ? (float)get.B * ((float)c.B / 255) : 0;
Color set = Color.FromArgb((int)r,(int)g,(int)b);
bmp.SetPixel(x, y, set);
if (pb != null)
pb.Increment(1);
}
}
return bmp;
}
示例2: generateObjByType
private void generateObjByType(List<string> typeList, string ownerName, string rootPath, List<string> pathList, ProgressBar fileBar)
{
int i = 0;
foreach (var type in typeList)
{
i++;
GenerateTemplate template = TemplateFactory.getInstance(type);
List<string> objNameList = template.getObjNameList(type);
string scriptStr = template.generateObjList(objNameList, type);
string path = template.writeStringToDisk(rootPath, type, scriptStr, ownerName);
pathList.Add(path);
for (int j = 1; j < objNameList.Count()+1; j++)
{
int incre = 100 / i / j;
fileBar.Increment(incre);
}
}
}
示例3: IncrementProgress
private void IncrementProgress( ProgressBar pb, int val )
{
pb.Increment ( val );
}
示例4: loadTestStudent
public void loadTestStudent(ProgressBar bar)
{
try
{
bar.Visible = true;
OpenFileDialog fichero = new OpenFileDialog();
fichero.Filter = "Excel (*.xls)|*.xls;*.xlsx";
bar.Visible = true;
ProjectBL pyBl = new ProjectBL(Program.ContextData);
FormBL formBl = new FormBL(Program.ContextData);
InventoryLineBL lineInvBl = new InventoryLineBL(Program.ContextData);
listStratumsAdded = new ArrayList();
if (fichero.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
excel.Application aplicacion;
excel.Workbook libros_trabajo;
excel.Worksheet hojas_trabajo;
excel.Range exlRange;
aplicacion = new excel.Application();
//Asignamos el libro que sera abierot
libros_trabajo = aplicacion.Workbooks.Open(fichero.FileName, 0, true, 5, "", "", true, excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
hojas_trabajo = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(1);
exlRange = hojas_trabajo.UsedRange;
//Recorremos el archivo excel como si fuera una matriz
//leemos las especies que se encuentran en la hoja
TStudentBL tStudentBL = new TStudentBL(Program.ContextData);
bar.Maximum = exlRange.Rows.Count;
bar.Value = 0;
string n = "", alpha = "", valor = "";
for (int i = 2; i <= exlRange.Rows.Count; i++)
{
TSTUDENT tableTstudent = new TSTUDENT();
n = (exlRange.Cells[i, 1] as excel.Range).Value + "";
alpha = (exlRange.Cells[i, 2] as excel.Range).Value + "";
valor = (exlRange.Cells[i, 3] as excel.Range).Value + "";
tableTstudent.N = int.Parse(n);
tableTstudent.ALPHA = decimal.Parse(alpha);
tableTstudent.VALOR = decimal.Parse(valor);
tStudentBL.InsertTStudent(tableTstudent);
string result = tStudentBL.SaveChanges();
if (result != "")
{
if (!result.Equals(""))
{
Error_Form errorForm = new Error_Form(result);
errorForm.MdiParent = (Form)bar.Parent.Parent;
errorForm.Show();
return;
}
}
bar.Increment(1);
}
MessageBox.Show("Los datos se cargaron correctamente.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
throw ex;
}
}
bar.Visible = false;
}
catch (Exception ex)
{
Error_Form errorForm = new Error_Form(ex.Message);
errorForm.MdiParent = (Form)bar.Parent.Parent;
errorForm.Show();
bar.Visible = false;
}
}
示例5: exportarExcelDiametricClass
public void exportarExcelDiametricClass(ProgressBar bar, DataGridView data, string Type, int numCLass)
{
try
{
SaveFileDialog fichero = new SaveFileDialog();
bar.Visible = true;
ProjectBL pyBl = new ProjectBL(Program.ContextData);
PROYECTO project = (PROYECTO)Program.Cache.Get("project");
if (project != null)
{
fichero.Filter = "Excel (*.xls)|*.xls";
fichero.FileName = "Reporte "+ Type+" clases diametricas "+ project.LUGAR + " "+ DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year;
if (fichero.ShowDialog() == DialogResult.OK)
{
//hacer visible la barra de progreso y fijar el valor maximo con el numero de registros a exportar
bar.Visible = true;
aplicacion = new excel.Application();
libros_trabajo = aplicacion.Workbooks.Add();
excel.Worksheet hoja_reporte;
hoja_reporte = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(1);
hoja_reporte.Name = "Reporte Clases Diametricas";
hoja_reporte.Cells[1, 1] = "Informacion del proyecto";
hoja_reporte.Cells[1, 1].Font.Bold = true;
hoja_reporte.Range[hoja_reporte.Cells[1, 1], hoja_reporte.Cells[1, data.Columns.Count]].Merge();
hoja_reporte.Cells[2, 1] = "Lugar";
hoja_reporte.Cells[2, 1].Font.Bold = true;
hoja_reporte.Cells[2, 2] = project.LUGAR.ToString();
hoja_reporte.Cells[2, 2].HorizontalAlignment =Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
hoja_reporte.Cells[2, 2].WrapText = true;
hoja_reporte.Cells[3, 1] = "Descripcion";
hoja_reporte.Cells[3, 1].Font.Bold = true;
hoja_reporte.Cells[3, 2] = project.DESCRIPCION.ToString();
hoja_reporte.Cells[3, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
hoja_reporte.Cells[3, 2].WrapText = true;
hoja_reporte.Cells[4, 1] = "Responsable";
hoja_reporte.Cells[4, 1].Font.Bold = true;
hoja_reporte.Cells[4, 2] = project.USUARIO.NOMBRES.ToString() + " " + project.USUARIO.APELLIDOS.ToString();
hoja_reporte.Cells[4, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
hoja_reporte.Cells[4, 2].WrapText = true;
hoja_reporte.Cells[5, 1] = "Reporte " + Type;
hoja_reporte.Cells[5, 1].Font.Bold = true;
hoja_reporte.Range[hoja_reporte.Cells[5, 1], hoja_reporte.Cells[5, data.Columns.Count]].Merge();
hoja_reporte.get_Range("A1", "O" + data.Columns.Count).HorizontalAlignment = excel.XlVAlign.xlVAlignCenter;
hoja_reporte.get_Range("A" + data.Rows.Count + 6, "O" + data.Columns.Count).HorizontalAlignment = excel.XlVAlign.xlVAlignCenter;
int col = 1;
foreach (DataGridViewColumn column in data.Columns)
{
hoja_reporte.Cells[6, col].NumberFormat = "@";
hoja_reporte.Cells[6, col] = column.HeaderText.ToString();
hoja_reporte.Cells[6, col].WrapText = true;
hoja_reporte.Cells[6, col].Font.Bold = true;
col++;
}
int i = 7;
bar.Minimum = 0;
bar.Maximum = data.Rows.Count;
foreach (DataGridViewRow row in data.Rows)
{
//de formulario extraer coord x y Y el estrato la linea numero de parcela y el usuario se puede hay que revisar muy bien esta parte
int j = 1;
foreach (DataGridViewTextBoxCell cell in row.Cells)
{
hoja_reporte.Cells[i, j].WrapText = true;
hoja_reporte.Cells[i, j] = cell.Value.ToString();
if (j <= (data.Columns.Count - (numCLass + 3)))
{
hoja_reporte.Cells[i, j].Font.Bold = true;
}
j++;
}
bar.Increment(1);
i++;
}
libros_trabajo.Worksheets.Add(hoja_reporte);
MessageBox.Show("Los datos se exportaron correctamente.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
bar.Visible = false;
libros_trabajo.SaveAs(fichero.FileName, excel.XlFileFormat.xlWorkbookNormal);
libros_trabajo.Close(true);
aplicacion.Quit();
System.Diagnostics.Process.Start(fichero.FileName);
}
}
else MessageBox.Show("No existe un proyecto abierto dentro del sistema.", "Operacion invalida", MessageBoxButtons.OK, MessageBoxIcon.Error);
bar.Visible = false;
}
catch (Exception ex)
{
bar.Visible = false;
//.........這裏部分代碼省略.........
示例6: Styles
public void Styles ()
{
ProgressBar c = new ProgressBar ();
//--
Assert.AreEqual(ProgressBarStyle.Blocks, c.Style, "orig=blocks");
//--
c.Style = ProgressBarStyle.Continuous;
//--
c.Style = ProgressBarStyle.Marquee;
// Increment and PerformStep are documented to fail in Marquee style.
try {
c.Increment (5);
Assert.Fail ("should have thrown -- Increment");
} catch (InvalidOperationException) {
}
try {
c.PerformStep ();
Assert.Fail ("should have thrown -- PerformStep ");
} catch (InvalidOperationException) {
}
// What about the other value-related properties? No fail apparently!
c.Value = 20;
c.Minimum = 5;
c.Maximum = 95;
//--
// Now undefined style values...
try {
c.Style = (ProgressBarStyle)4;
Assert.Fail("should have thrown -- bad style4");
} catch (global::System.ComponentModel.InvalidEnumArgumentException ex) {
//Console.WriteLine(ex.Message);
Assert.AreEqual(typeof(global::System.ComponentModel.InvalidEnumArgumentException), ex.GetType (), "Typeof bad style4");
Assert.AreEqual("value", ex.ParamName, "ParamName bad style 4");
}
try {
c.Style = (ProgressBarStyle)99;
Assert.Fail("should have thrown -- bad style99");
} catch (global::System.ComponentModel.InvalidEnumArgumentException ex) {
Assert.AreEqual (typeof(global::System.ComponentModel.InvalidEnumArgumentException), ex.GetType (), "Typeof bad style99");
Assert.AreEqual ("value", ex.ParamName, "ParamName bad style 99");
}
}
示例7: PerformStepAndIncrement
public void PerformStepAndIncrement ()
{
ProgressBar c = new ProgressBar ();
//
c.Value = 10;
c.Step = 30;
Assert.AreEqual (10, c.Value, "StepAt30_Init");
c.PerformStep ();
Assert.AreEqual (40, c.Value, "StepAt30_1");
c.PerformStep ();
Assert.AreEqual (70, c.Value, "StepAt30_2");
//
c.Value = 0;
c.Step = 20;
Assert.AreEqual (0, c.Value, "StepAt20_Init");
//
c.PerformStep ();
Assert.AreEqual (20, c.Value, "StepAt20_1");
c.PerformStep ();
Assert.AreEqual (40, c.Value, "StepAt20_2");
c.PerformStep ();
Assert.AreEqual (60, c.Value, "StepAt20_3");
c.PerformStep ();
Assert.AreEqual (80, c.Value, "StepAt20_4");
c.PerformStep ();
Assert.AreEqual (100, c.Value, "StepAt20_5");
c.PerformStep ();
Assert.AreEqual (100, c.Value, "StepAt20_6x");
c.PerformStep ();
Assert.AreEqual (100, c.Value, "StepAt20_7x");
//
c.Step = -20;
Assert.AreEqual (100, c.Value, "StepAt2Neg0_Init");
c.PerformStep ();
Assert.AreEqual (80, c.Value, "StepAtNeg20_1");
c.PerformStep ();
Assert.AreEqual (60, c.Value, "StepAtNeg20_2");
//
c.Step = -40;
Assert.AreEqual (60, c.Value, "StepAt2Neg40_Init");
c.PerformStep ();
Assert.AreEqual (20, c.Value, "StepAtNeg40_1");
c.PerformStep ();
Assert.AreEqual (0, c.Value, "StepAtNeg40_2");
c.PerformStep ();
Assert.AreEqual (0, c.Value, "StepAtNeg40_2");
//
c.Increment (30);
Assert.AreEqual (30, c.Value, "Increment30_1");
c.Increment (30);
Assert.AreEqual (60, c.Value, "Increment30_2");
c.Increment (30);
Assert.AreEqual (90, c.Value, "Increment30_3");
c.Increment (30);
Assert.AreEqual (100, c.Value, "Increment30_4x");
}
示例8: prepareScriptOfTable
/*************************************
* get table columns and columns values
*************************************/
private string prepareScriptOfTable(OracleConnection conn, string tableName, string ownerName, ProgressBar fileBar)
{
StringBuilder scriptCol = new StringBuilder();
StringBuilder scriptFinal = new StringBuilder();
scriptFinal.Append("SET DEFINE OFF; " + RETCHAR);
scriptFinal.Append("DELETE FROM " + ownerName + "." + tableName + ";" + RETCHAR);
// Step 1: get all columns name of the table
string sqlText = DBSQL.QUERY_TABLE_COLUMNS;
sqlText = sqlText.Replace("?", tableName);
DataSet ds = OracleClient.getResultTable(conn, sqlText);
List<string> colList = new List<string>();
if (ds.Tables.Count > 0)
{
scriptCol.Append("INSERT INTO " + ownerName + "." + tableName + "(");
// prepare one row with the column type
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
colList.Add(ds.Tables[0].Rows[i][1].ToString());
if (i != ds.Tables[0].Rows.Count - 1)
{
scriptCol.Append(ds.Tables[0].Rows[i][0] + ",");
}
else
{
scriptCol.Append(ds.Tables[0].Rows[i][0] + ")");
}
}
scriptCol.Append(RETCHAR);
scriptCol.Append(" VALUES( ");
}
// Step 2: get all values and combine to the insert script
string sqlValueText = DBSQL.QUERY_COLUMNS_VALUES;
sqlValueText = sqlValueText.Replace("?", tableName);
DataSet valueDS = OracleClient.getResultTable(conn, sqlValueText);
if (valueDS.Tables.Count > 0)
{
for (int i = 0; i < valueDS.Tables[0].Rows.Count; i++)
{
// first append the column script
scriptFinal.Append(scriptCol);
string columnValue = "";
for (int j = 0; j < colList.Count; j++)
{
columnValue = getDataTypeScript(valueDS.Tables[0].Rows[i][j].ToString(), colList[j]);
if (j != colList.Count - 1)
{
scriptFinal.Append(columnValue + ",");
}
else
{
scriptFinal.Append(columnValue);
}
// update progress bar
int incre = 100 / (i + 1) / (j + 1);
fileBar.Increment(incre);
}
scriptFinal.Append(");" + RETCHAR);
}
}
scriptFinal.Append("COMMIT;");
return scriptFinal.ToString();
}
示例9: insertStock
/*Precondition:
Postcondition: Loops through list of stock passed in, and inserts them into SQLite DB*/
public void insertStock(List<Stock> allStock, ProgressBar progBar)
{
//Check to see if stock table exists
if (checkForTable("Stock"))
{
//Open DB and start transcation - transaction hugely increases speed of insert
dbConnection.Open();
SQLiteTransaction transaction = dbConnection.BeginTransaction();
//Loop through all stock
foreach (Stock s in allStock)
{
string stockInsert = "";
int quantity = s.quantity;
string note = SyntaxHelper.escapeSingleQuotes(s.note);
string author = SyntaxHelper.escapeSingleQuotes(s.author);
string title = SyntaxHelper.escapeSingleQuotes(s.title);
string subtitle = SyntaxHelper.escapeSingleQuotes(s.subtitle);
string publisher = SyntaxHelper.escapeSingleQuotes(s.publisher);
string description = SyntaxHelper.escapeSingleQuotes(s.description);
string comments = SyntaxHelper.escapeSingleQuotes(s.comments);
double price = s.price;
string subject = SyntaxHelper.escapeSingleQuotes(s.subject);
string catalogue = SyntaxHelper.escapeSingleQuotes(s.catalogue);
string initials = SyntaxHelper.escapeSingleQuotes(s.initials);
string sales = SyntaxHelper.escapeSingleQuotes(s.sales);
string bookID = SyntaxHelper.escapeSingleQuotes(s.bookID);
string dateEntered = SyntaxHelper.escapeSingleQuotes(s.dateEntered);
int stockID = s.stockID;
//Build insert command. If stock has an ID insert it with that ID if not (new stock) and insert with a new ID using autoincrement from SQLite
if (s.stockID == -1)
{
stockInsert = "INSERT INTO Stock VALUES(null, '" + quantity + "', '" + note + "', '" + author + "', '" + title + "', '" + subtitle + "', '" + publisher
+ "', '" + description + "', '" + comments + "', '" + price + "', '" + subject + "', '" + catalogue + "', '" + initials + "', '" + sales + "', '" + bookID +
"', '" + dateEntered + "')";
}
else
{
stockInsert = "INSERT INTO Stock VALUES(" + stockID + ", '" + quantity + "', '" + note + "', '" + author + "', '" + title + "', '" + subtitle + "', '" + publisher
+ "', '" + description + "', '" + comments + "', '" + price + "', '" + subject + "', '" + catalogue + "', '" + initials + "', '" + sales + "', '" + bookID +
"', '" + dateEntered + "')";
}
SQLiteCommand insertCommand = new SQLiteCommand(stockInsert, dbConnection);
insertCommand.ExecuteNonQuery();
//Update UI for user to see progress
progBar.Increment(1);
}
//Commit transaction and close connection
transaction.Commit();
dbConnection.Close();
}
}
示例10: insertOrders
/*Precondition:
Postcondition: Loops through list of stock passed in, and inserts them into SQLite DB*/
public void insertOrders(List<Order> allOrders, ProgressBar progBar)
{
//Check to see if orders table exists
if (checkForTable("Orders"))
{
//Open DB and start transcation - transaction hugely increases speed of insert
dbConnection.Open();
SQLiteTransaction transaction = dbConnection.BeginTransaction();
//Loop through all stock
foreach (Order o in allOrders)
{
string orderInsert = "";
string firstName = SyntaxHelper.escapeSingleQuotes(o.firstName);
string lastName = SyntaxHelper.escapeSingleQuotes(o.lastName);
string institution = SyntaxHelper.escapeSingleQuotes(o.institution);
string postcode = SyntaxHelper.escapeSingleQuotes(o.postcode);
string orderReference = SyntaxHelper.escapeSingleQuotes(o.orderReference);
string progress = SyntaxHelper.escapeSingleQuotes(o.progress);
double freightCost = o.freightCost;
int invoiceNo = o.invoiceNo;
DateTime invoiceDate = o.invoiceDate;
string comments = SyntaxHelper.escapeSingleQuotes(o.comments);
int customerID = o.customerID;
int orderID = o.orderID;
//Build insert command. If order has an ID insert it with that ID if not (new order) and insert with a new ID using autoincrement from SQLite
if (o.orderID == -1)
{
orderInsert = "INSERT INTO Orders VALUES(null, '" + firstName + "', '" + lastName + "', '" + institution + "', '" + postcode + "', '" + orderReference + "', '" +
progress + "', '" + freightCost + "', '" + invoiceNo + "', '" + invoiceDate.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + comments + "', '" + customerID + "')";
}
else
{
orderInsert = "INSERT INTO Orders VALUES(" + orderID + ", '" + firstName + "', '" + lastName + "', '" + institution + "', '" + postcode + "', '" + orderReference + "', '" +
progress + "', '" + freightCost + "', '" + invoiceNo + "', '" + invoiceDate.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + comments + "', '" + customerID + "')";
}
SQLiteCommand insertCommand = new SQLiteCommand(orderInsert, dbConnection);
insertCommand.ExecuteNonQuery();
//Update UI for user to see progress
progBar.Increment(1);
}
//Commit transaction and close connection
transaction.Commit();
dbConnection.Close();
}
}
示例11: insertOrderedStock
/*Precondition:
Postcondition: Loops through all of the OrderedStock and inserts them into SQLite DB, updates user with progress*/
public void insertOrderedStock(List<OrderedStock> allOrderedStock, ProgressBar progBar)
{
//Check to see if orderedstock table exists
if (checkForTable("OrderedStock"))
{
//Open DB and start transcation - transaction hugely increases speed of insert
dbConnection.Open();
SQLiteTransaction transaction = dbConnection.BeginTransaction();
//Loop through all orderedStock
foreach (OrderedStock o in allOrderedStock)
{
string orderedStockInsert = "";
int orderID = o.orderID;
int stockID = o.stockID;
int quantity = o.quantity;
string author = SyntaxHelper.escapeSingleQuotes(o.author);
string title = SyntaxHelper.escapeSingleQuotes(o.title);
double price = o.price;
string bookID = SyntaxHelper.escapeSingleQuotes(o.bookID);
double discount = o.discount;
int orderedStockID = o.orderedStockID;
//Build insert command. If OrderedStock has an ID insert it with that ID if not (new orderedSock) and insert with a new ID using autoincrement from SQLite
if (o.orderedStockID == -1)
{
orderedStockInsert = "INSERT INTO OrderedStock VALUES(null, " + orderID + ", " + stockID + ", " + quantity + ", '" + author + "', '" + title + "', '" +
price + "', '" + bookID + "', '" + discount + "')";
}
else
{
orderedStockInsert = "INSERT INTO OrderedStock VALUES(" + orderedStockID + ", " + orderID + ", " + stockID + ", " + quantity + ", '" + author + "', '" + title + "', '" +
price + "', '" + bookID + "', '" + discount + "')";
}
SQLiteCommand insertCommand = new SQLiteCommand(orderedStockInsert, dbConnection);
insertCommand.ExecuteNonQuery();
//Update UI for user to see progress
progBar.Increment(1);
}
//Commit transaction and close connection
transaction.Commit();
dbConnection.Close();
}
}
示例12: insertCustomers
/*Precondition:
Postcondition: Loops through list of customers passed in, and inserts them into SQLite DB*/
public void insertCustomers(List<Customer> customers, ProgressBar progBar)
{
//Check to see if customer table exists
if (checkForTable("Customer"))
{
//Open DB and start transcation - transaction hugely increases speed of insert
dbConnection.Open();
SQLiteTransaction transaction = dbConnection.BeginTransaction();
//Loop through all customers
foreach (Customer c in customers)
{
int custID = c.custID;
string firstName = SyntaxHelper.escapeSingleQuotes(c.firstName);
string lastName = SyntaxHelper.escapeSingleQuotes(c.lastName);
string institution = SyntaxHelper.escapeSingleQuotes(c.institution);
string address1 = SyntaxHelper.escapeSingleQuotes(c.address1);
string address2 = SyntaxHelper.escapeSingleQuotes(c.address2);
string address3 = SyntaxHelper.escapeSingleQuotes(c.address3);
string country = SyntaxHelper.escapeSingleQuotes(c.country);
string postcode = SyntaxHelper.escapeSingleQuotes(c.postCode);
string email = SyntaxHelper.escapeSingleQuotes(c.email);
string comments = SyntaxHelper.escapeSingleQuotes(c.comments);
string sales = SyntaxHelper.escapeSingleQuotes(c.sales);
string payment = SyntaxHelper.escapeSingleQuotes(c.payment);
string customerInsert = "";
//Build insert command. If customer has an ID insert it with that ID if not (new customer) and insert with a new ID using autoincrement from SQLite
if (c.custID == -1)
{
customerInsert = "INSERT INTO Customer VALUES(null, '" + firstName + "', '" + lastName + "', '" + institution + "', '" + address1 + "', '" + address2 + "', '" +
address3 + "', '" + country + "', '" + postcode + "', '" + email + "', '" + comments + "', '" + sales + "', '" + payment + "')";
}
else
{
customerInsert = "INSERT INTO Customer VALUES(" + custID + ", '" + firstName + "', '" + lastName + "', '" + institution + "', '" + address1 + "', '" + address2 + "', '" + address3 +
"', '" + country + "', '" + postcode + "', '" + email + "', '" + comments + "', '" + sales + "', '" + payment + "')";
}
SQLiteCommand insertCommand = new SQLiteCommand(customerInsert, dbConnection);
insertCommand.ExecuteNonQuery();
//Update UI for user to see progress
progBar.Increment(1);
}
//Commit transaction and close connection
transaction.Commit();
dbConnection.Close();
}
}
示例13: IncreaseProgress
public void IncreaseProgress(ProgressBar control, int increment)
{
if (control.InvokeRequired)
{
control.Invoke(new ControlProgressBar(IncreaseProgress), new object[] { control, increment });
}
else
{
control.Increment(increment);
}
}
示例14: UpdateProgressInvoker
private void UpdateProgressInvoker(int delta, ProgressBar p)
{
p.Increment(delta);
}
示例15: Copy
/// <summary>
// SOURCE: did up where this cam efrom
/// xDirectory.Copy() - Copy a Source Directory
/// and it's SubDirectories/Files
/// </summary>
/// <param name="diSource">The Source Directory</param>
/// <param name="diDestination">The Destination Directory</param>
/// <param name="FileFilter">The File Filter
/// (Standard Windows Filter Parameter, Wildcards: "*" and "?")</param>
/// <param name="DirectoryFilter">The Directory Filter
/// (Standard Windows Filter Parameter, Wildcards: "*" and "?")</param>
/// <param name="Overwrite">Whether or not to Overwrite
/// a Destination File if it Exists.</param>
/// <param name="FolderLimit">Iteration Limit - Total Number
/// of Folders/SubFolders to Copy</param>
public static void Copy(DirectoryInfo diSource,
DirectoryInfo diDestination,
string FileFilter, string DirectoryFilter,
bool Overwrite, int FolderLimit, ProgressBar bar)
{
int iterator = 0;
List<DirectoryInfo> diSourceList =
new List<DirectoryInfo>();
List<FileInfo> fiSourceList =
new List<FileInfo>();
try
{
///// Error Checking /////
if (diSource == null)
throw new ArgumentException("Source Directory: NULL");
if (diDestination == null)
throw new ArgumentException("Destination Directory: NULL");
if (!diSource.Exists)
throw new IOException("Source Directory: Does Not Exist");
if (!(FolderLimit > 0))
throw new ArgumentException("Folder Limit: Less Than 1");
if (DirectoryFilter == null || DirectoryFilter == string.Empty)
DirectoryFilter = "*";
if (FileFilter == null || FileFilter == string.Empty)
FileFilter = "*";
if (bar == null)
throw new ArgumentException("Copy - Progress Bar: NULL");
///// Add Source Directory to List /////
diSourceList.Add(diSource);
///// First Section: Get Folder/File Listing /////
while (iterator < diSourceList.Count && iterator < FolderLimit)
{
foreach (DirectoryInfo di in
diSourceList[iterator].GetDirectories(DirectoryFilter))
diSourceList.Add(di);
foreach (FileInfo fi in
diSourceList[iterator].GetFiles(FileFilter))
fiSourceList.Add(fi);
iterator++;
}
if (bar != null)
{
bar.Maximum = fiSourceList.Count;
bar.Minimum = 0;
bar.Step = 1;
bar.Value = 0;
}
///// Second Section: Create Folders from Listing /////
foreach (DirectoryInfo di in diSourceList)
{
if (di.Exists)
{
string sFolderPath = diDestination.FullName + @"\" +
di.FullName.Remove(0, diSource.FullName.Length);
///// Prevent Silly IOException /////
if (!Directory.Exists(sFolderPath))
Directory.CreateDirectory(sFolderPath);
}
}
///// Third Section: Copy Files from Listing /////
foreach (FileInfo fi in fiSourceList)
{
if (fi.Exists)
{
string sFilePath = diDestination.FullName + @"\" +
fi.FullName.Remove(0, diSource.FullName.Length);
//// Better Overwrite Test W/O IOException from CopyTo() ////
if (Overwrite)
fi.CopyTo(sFilePath, true);
else
{
///// Prevent Silly IOException /////
if (!File.Exists(sFilePath))
fi.CopyTo(sFilePath, true);
}
if (bar != null)
{
bar.Increment(1);
//.........這裏部分代碼省略.........