public void ExportProducts() { SqlCompactConnection conn = new SqlCompactConnection(); Product p = new Product(); ProductCollection ProdCol = new ProductCollection(); int i = 0; try { string where = "activeflag=1"; string orderby = "productid"; ProdCol = p.GetProductsCollection(where, orderby); conn.DropProdctTable(); conn.CreateProductTable(); conn.SynchForm = this; conn.AddProduct(ProdCol); } catch (Exception ex) { log.Write("Product Record faild to export (id=" + ProdCol[i].ProductID + "). Error:" + ex.Message, "frmSynch.ExportProduct"); MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { conn.CloseDatabase(); conn = null; } }
public void ExportAddresses() { SqlCompactConnection conn = new SqlCompactConnection(); try { Address add = new Address(); AddressCollection AddCol = new AddressCollection(); string where = "addressid in (select Addressid from customer where activeflag=1)"; string orderby = "addressid"; AddCol = add.GetAddressCollection(where, orderby); conn.DropAddressTable(); conn.CreateAddressTable(); conn.SynchForm = this; conn.AddAddress(AddCol); } catch (Exception ex) { MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { conn.CloseDatabase(); conn = null; } }
public void ExportCustomers() { SqlCompactConnection conn = new SqlCompactConnection(); try { Customer cus = new Customer(); CustomerCollection CusCol = new CustomerCollection(); string where = "customerid > 0 AND ActiveFlag=1"; string orderby = "customerid"; CusCol = cus.GetCustomersCollection(where, orderby); conn.DropCustomerTable(); conn.CreateCustomerTable(); conn.SynchForm = this; conn.AddCustomer(CusCol); } catch (Exception ex) { MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { conn.CloseDatabase(); conn = null; } }
public void ExportTerritories() { SqlCompactConnection conn = new SqlCompactConnection(); SalesTerritory ter = new SalesTerritory(); try { SalesTerritoryCollection colTerr = ter.GetAllSalesTerritoryCollection(); conn.SynchForm = this; conn.DropSalesTerritoryTable(); conn.CreateTerritoryTable(); conn.AddSalesTerritory(colTerr); ter = null; colTerr = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.CloseDatabase(); conn = null; } }
public void ExportCategories() { SqlCompactConnection conn = new SqlCompactConnection(); try { StripStatus.Text = "Products Sub Categories.."; ProductSubcategory sub = new ProductSubcategory(); ProductCategory cat = new ProductCategory(); conn.DropProdctSubCategoryTable(); conn.CreateProdctSubCategoryTable(); ProductSubcategoryCollection subCol = sub.GetAllProductSubcategoryCollection(); conn.SynchForm = this; conn.AddProductSubCategory(subCol); StripStatus.Text = "Products Categories.."; conn.DropProdctCategoryTable(); conn.CreateProdctCategoryTable(); ProductCategoryCollection catCol = cat.GetAllProductCategoryCollection(); conn.AddProductCategory(catCol); sub = null; cat = null; subCol = null; catCol = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.CloseDatabase(); conn = null; } }
public void ExportSpecialOffers() { SqlCompactConnection conn = new SqlCompactConnection(); SpecialOffer so = new SpecialOffer(); SpecialOfferCollection soCol = new SpecialOfferCollection(); SpecialOfferProduct sop = new SpecialOfferProduct(); SpecialOfferProductCollection sopCol = new SpecialOfferProductCollection(); string where = "startdate <= getdate() and enddate >= getdate()"; string orderby = "specialofferid"; try { //ds = q.GetDataSet(false, sql); soCol = so.GetSpecialOffersCollection(where, orderby); conn.SynchForm = this; conn.DropSepcialOfferTable(); conn.CreateSpecialOfferTable(); conn.AddSpecialOffer(soCol); where = "specialofferid in (select specialofferid from specialoffer where startdate <= getdate() and enddate >= getdate())"; orderby = "specialofferid"; sopCol = sop.GetSpecialOfferProductsCollection(where, orderby); conn.DropSepcialOfferProductTable(); conn.CreateSpecialOfferProductTable(); conn.AddSpecialOfferProduct(sopCol); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.CloseDatabase(); conn = null; so = null; soCol = null; sop = null; sopCol = null; //ds.Dispose(); // q = null; } }
public void ExportDueInvoices() { SqlCompactConnection conn = new SqlCompactConnection(); SalesInvoiceHeader sih = new SalesInvoiceHeader(); DataSet ds = new DataSet(); int count = 0; try { ds = sih.GetInvoicesBalance(); count = ds.Tables[0].Rows.Count; progressBar1.Minimum = 0; progressBar1.Maximum = count; lblStatus.Text = "Exporting Invoices (" + count.ToString() + " records)"; RefreshForm(); conn.DropInvoicesBalanceTable(); //progressBar1.Value = count/5 ; RefreshForm(); conn.SynchForm = this; conn.CreateInvoicesBalanceTable(); //progressBar1.Value = count * 2/5; RefreshForm(); if (ds != null) { conn.InsertInvoicesBalance(ds.Tables[0]); } //progressBar1.Value = count ; //RefreshForm(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.CloseDatabase(); conn = null; } }
private void UpdateMobileSalesOrder() { SqlCompactConnection conn = new SqlCompactConnection(); try { conn.connect(); DataTable dt = new DataTable(); string sql = "select salesorderid,salespersonid from salesorderheader where status <> 1"; dt = conn.GetDataTable(sql); int rows = dt.Rows.Count; int i = 0; progressBar1.Minimum = 0; progressBar1.Maximum = rows; foreach (DataRow dr in dt.Rows) { //Get sales order data from server. SalesOrderHeader soh = new SalesOrderHeader(); SalesOrderHeaderCollection SohCol = new SalesOrderHeaderCollection(); string where = "CurrencyRateID=" + dr["SalesOrderID"].ToString(); where += " and SalesPersonID=" + dr["SalesPersonID"].ToString(); string orderby = "SalesOrderID"; SohCol = soh.GetSalesOrderHeaderCollection(where, orderby); int count = SohCol.Count; if (count == 0) { continue; } //update salesorder in mobile. SohCol[0].Status = 9; soh.UpdateSalesOrderHeaderMobile(SohCol[0]); //get server order details SalesOrderDetail sod = new SalesOrderDetail(); SalesOrderDetailCollection SodCol = new SalesOrderDetailCollection(); where = "SalesOrderID=" + SohCol[0].SalesOrderID; orderby = "SalesOrderID"; SodCol = sod.GetSalesOrderDetailCollection(where, orderby); //Delete sales order details from mobile sod.DeleteSalesOrderDetailMobile(SohCol[0].CurrencyRateID); //copy sales order details from the server to the mobile. for (int j = 0; j < SodCol.Count; j++) { SodCol[j].SalesOrderID = SohCol[0].CurrencyRateID; sod.AddSalesOrderDetailsMobile(SodCol[j]); } i++; progressBar1.Value = i; RefreshForm(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { conn.CloseDatabase(); conn = null; } }