示例#1
0
        private void exportToMobileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSynchImport synch = new frmSynchImport();

            synch.ExportData();
        }
示例#2
0
        private void importMobileDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSynchImport synch = new frmSynchImport();

            synch.ImportData();
            //try
            //{
            //    SqlCompactConnection conn = new SqlCompactConnection();
            //    conn.connect();
            //    DataTable dtSoh = new DataTable();
            //    string sql = "select * from salesorderheader where status=1";
            //    dtSoh = conn.GetDataTable(sql);

            //    //SalesOrderHeaderTableAdapter soh = new SalesOrderHeaderTableAdapter();
            //    //SalesOrderDetailTableAdapter sod = new SalesOrderDetailTableAdapter();

            //    SalesOrderHeader OrderHeader = new SalesOrderHeader();

            //    int rows = dtSoh.Rows.Count;
            //    if (rows == 0)
            //    {
            //        MessageBox.Show("There are no records to import", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //        return;
            //    }
            //    int iCount = 0;

            //    foreach (DataRow dr in dtSoh.Rows)
            //    {
            //        int OrderID = Int32.Parse(dr["SalesOrderID"].ToString());
            //        OrderHeader.OrderDate = DateTime.Parse(dr["OrderDate"].ToString());
            //        OrderHeader.ShipDate = DateTime.Parse(dr["ShipDate"].ToString());
            //        OrderHeader.DueDate = DateTime.Parse(dr["DueDate"].ToString());
            //        OrderHeader.SalesOrderNumber = dr["SalesOrderNumber"].ToString();
            //        OrderHeader.PurchaseOrderNumber = dr["PurchaseOrderNumber"].ToString();
            //        OrderHeader.CustomerID = Int32.Parse(dr["CustomerID"].ToString());
            //        OrderHeader.SalesPersonID = Int32.Parse(dr["SalesPersonID"].ToString());
            //        OrderHeader.BillToAddressID = Int32.Parse(dr["BillToAddressID"].ToString());
            //        OrderHeader.ShipToAddressID = Int32.Parse(dr["ShipToAddressID"].ToString());
            //        OrderHeader.ShipMethodID = Int32.Parse(dr["ShipMethodID"].ToString());
            //        OrderHeader.Status = byte.Parse(dr["Status"].ToString());
            //        OrderHeader.SubTotal = decimal.Parse(dr["SubTotal"].ToString());
            //        OrderHeader.TaxAmt = decimal.Parse(dr["TaxAmt"].ToString());
            //        OrderHeader.TotalDue = decimal.Parse(dr["TotalDue"].ToString());
            //        OrderHeader.Comment = "Mobile Order";
            //        //save the mobile order id in currencyrateid
            //        OrderHeader.CurrencyRateID = OrderID;

            //        int ServerOrderID = OrderHeader.AddSalesOrderHeader(OrderHeader);

            //        //Get order details in the mobile db
            //        DataTable dtSod = new DataTable();
            //        sql = "select * from salesorderdetail where salesorderid=" + OrderID.ToString();
            //        dtSod = conn.GetDataTable(sql);
            //        //insert the details in the server
            //        foreach (DataRow drow in dtSod.Rows)
            //        {
            //            SalesOrderDetail OrderDetails = new SalesOrderDetail();
            //            OrderDetails.SalesOrderID = ServerOrderID;
            //            OrderDetails.ProductID = Int32.Parse(drow["ProductID"].ToString());
            //            OrderDetails.OrderQty = short.Parse(drow["OrderQty"].ToString());
            //            OrderDetails.UnitPrice = decimal.Parse(drow["UnitPrice"].ToString());
            //            OrderDetails.SpecialOfferID = Int32.Parse(drow["SpecialOfferID"].ToString());
            //            OrderDetails.UnitPriceDiscount = decimal.Parse(drow["UnitPriceDiscount"].ToString());
            //            OrderDetails.LineTotal = decimal.Parse(drow["LineTotal"].ToString());
            //            OrderDetails.CarrierTrackingNumber = "";
            //            OrderDetails.AddSalesOrderDetail(OrderDetails);

            //        }
            //        iCount++;
            //        //update the status of header record in the mobile to Uploaded
            //        sql = "update salesorderheader set status=9 where salesorderid=" + OrderID;
            //        conn.Execute(sql);
            //       //soh.UpdateStatusByID(OrderID);


            //    }
            //    conn.CloseDatabase();
            //    MessageBox.Show(iCount.ToString() + " of " + rows.ToString() + " records imported successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}

            /*SqlCompactConnection con = new SqlCompactConnection();
             * try
             * {
             *  con.connect();
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Error);
             * }
             * finally
             * {
             *  con = null;
             * }*/
        }