Esempio n. 1
0
        public void MouseClick(object sender, EventArgs e)
        {
            Button bt = (Button)sender;

            flowLayoutPanel1.Controls.Clear();
            DataTable dt = ConnectionClass.Selectcommand("select category_id from Category where CategoryName='" + bt.Text + "'");

            try
            {
                DataTable dt11 = ConnectionClass.Selectcommand("select ProductName from Product where Category_id='" + dt.Rows[0][0].ToString() + "'");
                foreach (DataRow row in dt11.Rows)
                {
                    AddNewSubButton(row[0].ToString());
                }
            }
            catch { }
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt1 = ConnectionClass.Selectcommand("select Type from Category");

            foreach (DataRow row in dt1.Rows)
            {
                comboBox1.Items.Add(row[0].ToString());
            }

            DataTable dt = ConnectionClass.Selectcommand("select type from language");

            if (dt.Rows[0][0].ToString() == "English")
            {
                English();
            }
            else
            {
                Urdu();
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (BusinessName.Text == "" || BusinessName.Text == null)
                {
                    MessageBox.Show("Please Fill the TextBox First", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    ConnectionClass.InsertCommand("insert into Business_type Values('" + BusinessName.Text + "','" + Description.Text + "')");
                    MessageBox.Show("Successfully Added", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    BusinessName.Text = Description.Text = "";
                }
            }
            catch
            {
            }
        }
Esempio n. 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            InitializeTimer();
            //if (InternetConnection.IsConnectedToInternet())
            //{
            //    List<SalesDetail> lst = new List<SalesDetail>();
            //    businessCode = DatabaseActivities.GetBusinessCode();
            //    lst = OnlineActivities.GetOnlineSalesDetailDB();
            //    foreach (var items in lst)
            //    {
            //        OnlineActivities.SendOnlineSalesDetail(items.ProductID, items.ProductName, Convert.ToInt32(items.Quantity), items.UnitPrice, items.TotalPrice, items.SalesMasterIDLocal, 1, businessCode);

            //    }
            //    OnlineActivities.UpdateSalesDetailConnection();
            //}
            //else
            //{
            //    lblResponse.Text = "Offline So not Sales Details to be inserted";
            //}
            editbox.Visible = false;
            autoCompleteMethod();
            //DataTable   dt = ConnectionClass.Selectcommand("select type from language");
            //if (dt.Rows[0][0].ToString() == "English")
            //{
            //    English();
            //}
            //else
            //{
            //    Urdu();
            //}

            DataTable dt11 = ConnectionClass.Selectcommand("select CategoryName from Category");

            foreach (DataRow row in dt11.Rows)
            {
                AddNewButton(row[0].ToString());
            }
        }
Esempio n. 5
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string message = "";

            #region var initialisation
            long salesMasterID;
            totalAmount  = Convert.ToDouble(LbTotal.Text);
            discount     = Convert.ToDecimal(LbDiscount.Text);
            salesTaxRate = 15.00;
            salesTax     = Convert.ToDouble(LBKpra.Text);
            netAmount    = Convert.ToDouble(LbPayable.Text);
            paid         = Convert.ToDouble(TBPaid.Text);
            todayTime    = DateTime.Parse(System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff"), CultureInfo.InvariantCulture);
            // todayTime = DateTime.Parse("2018-18-9 03:05.000");
            description  = "Signed by Vendor";
            otherCharges = 10.00;
            businessId   = 1;
            businessCode = DatabaseActivities.GetBusinessCode();
            stationId    = 0;
            // salesMasterID = OnlineActivities.GetLastMasterIDLocal();
            #endregion end calculations
            #region Local Data Store Operation
            Thread threadSalesLocal = new Thread(() =>
            {
                ConnectionClass.InsertCommand("insert into sales_Master2 values('" + Convert.ToDecimal(totalAmount) + "','" + discount + "','15','" + salesTax + "','" + Convert.ToDecimal(netAmount) + "','" + Convert.ToDecimal(paid) + "','" + InternetConnection.GetBusinessCode() + "','1','" + System.DateTime.Today.ToString("yyyy-MM-dd") + "','1','" + DateTime.Parse(System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff")) + "')");
            });
            threadSalesLocal.Start();
            threadSalesLocal.Join();
            //detail list for local
            List <SalesDetail> salesDetailLstLocal = new List <SalesDetail>();

            foreach (ListViewItem item in listView1.Items)
            {
                DataTable   dt          = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master2");
                SalesDetail salesDetail = new SalesDetail();
                salesDetail.ProductID          = Convert.ToInt64(item.SubItems[0].Text);
                salesDetail.ProductName        = item.SubItems[1].Text.ToString();
                salesDetail.Quantity           = Convert.ToInt32(item.SubItems[2].Text.ToString());
                salesDetail.UnitPrice          = Convert.ToDecimal(item.SubItems[3].Text.ToString());
                salesDetail.TotalPrice         = Convert.ToDecimal(item.SubItems[4].Text.ToString());
                salesDetail.SalesMasterIDLocal = Convert.ToInt64(dt.Rows[0][0].ToString());
                salesDetailLstLocal.Add(salesDetail);
            }


            Thread threadDetailLocal = new Thread(() =>
            {
                foreach (var item in salesDetailLstLocal)
                {
                    SalesDetail salesDetail = new SalesDetail();
                    DataTable dt            = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master2");
                    ConnectionClass.InsertCommand("insert into Sales_Details2 " +
                                                  " values ('" +
                                                  item.ProductID + "','" +
                                                  item.ProductName + "','" +
                                                  item.Quantity + "','" +
                                                  item.UnitPrice + "','" +
                                                  item.TotalPrice + "','" +
                                                  dt.Rows[0][0].ToString() + "','True')");
                }
            });
            threadDetailLocal.Start();
            threadDetailLocal.Join();
            PrintReport();
            ClearItems();

            lblHttpResponse.Text += "items cleared";
            #endregion
            Thread t = new Thread(() =>
            {
                if (InternetConnection.IsConnectedToInternet())
                {
                    // MessageBox.Show(WebAPIResource.statusCodes);
                    //    lblHttpResponse.Text += WebAPIResource.statusCodes.ToString();
                    //message = WebAPIResource.statusCodes.ToString();
                    ConnectionClass.InsertCommand("insert into sales_Master values('" + Convert.ToDecimal(totalAmount) + "','" + discount + "','15','" + salesTax + "','" + Convert.ToDecimal(netAmount) + "','" + Convert.ToDecimal(paid) + "','" + InternetConnection.GetBusinessCode() + "','1','" + System.DateTime.Today.ToString("yyyy-MM-dd") + "','1','" + DateTime.Parse(System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff")) + "')");

                    #region comments
                    //List<SalesMasterForLocal> listLocalSalesMaster = new List<SalesMasterForLocal>();
                    //OnlineActivities.StoreSalesMasterDataOnline(Convert.ToDecimal(LbTotal.Text), Convert.ToDecimal(LbDiscount.Text),
                    //     Convert.ToDecimal(ConfigurationManager.AppSettings["sales_tax"]), Convert.ToDecimal(LBKpra.Text),
                    //     Convert.ToDecimal(LbPayable.Text), Convert.ToDecimal(TBPaid.Text),true,
                    //     InternetConnection.GetBusinessCode(),1,System.DateTime.Today.ToString("yyyy-MM-dd"),
                    //     DateTime.Parse(System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff")));
                    // //SalesMasterForLocal salesMasterLocalStorage = new SalesMasterForLocal();
                    //salesMasterLocalStorage.TotalAmount = Convert.ToDecimal(LbTotal.Text);
                    //salesMasterLocalStorage.Discount = Convert.ToDecimal(LbDiscount.Text);
                    //salesMasterLocalStorage.SalesTaxRate = Convert.ToDecimal(ConfigurationManager.AppSettings["sales_tax"]);
                    //salesMasterLocalStorage.SalesTax = Convert.ToDecimal(LBKpra.Text);
                    //salesMasterLocalStorage.NetAmount = Convert.ToDecimal(LbPayable.Text);
                    //salesMasterLocalStorage.Paid = Convert.ToDecimal(TBPaid.Text);
                    //salesMasterLocalStorage.isConnected = true;
                    //salesMasterLocalStorage.BusinessCode = InternetConnection.GetBusinessCode();
                    //salesMasterLocalStorage.StationID = 1;
                    //salesMasterLocalStorage.SalesDate = System.DateTime.Today.ToString("yyyy-MM-dd");
                    //salesMasterLocalStorage.SalesDate2 = DateTime.Parse(System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff"));
                    //listLocalSalesMaster.Add(salesMasterLocalStorage);
                    #endregion
                }
                else
                {
                    // MessageBox.Show(WebAPIResource.statusCodes);
                    //  lblHttpResponse.Text += WebAPIResource.statusCodes.ToString();
                    ConnectionClass.InsertCommand("insert into sales_Master values('" + Convert.ToDecimal(totalAmount) + "','" + discount + "','15','" + salesTax + "','" + Convert.ToDecimal(netAmount) + "','" + Convert.ToDecimal(paid) + "','" + InternetConnection.GetBusinessCode() + "','1','" + System.DateTime.Today.ToString("yyyy-MM-dd") + "','0','" + DateTime.Parse(System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff")) + "')");

                    // lblResponse.Text += "\nSales Master DATA TRANSFER FAILS!";
                }
            }
                                  );
            t.Start();
            t.IsBackground = true;
            t.Join();

            //lblHttpResponse.Text += message.ToString();
            Thread threadSales = new Thread(() =>
            {
                if (InternetConnection.IsConnectedToInternet())
                {
                    DataTable dt = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");
                    OnlineActivities.SendOnlineInvoice(totalAmount, discount,
                                                       salesTaxRate, salesTax, netAmount, paid,
                                                       todayTime, description,
                                                       otherCharges, Convert.ToInt64(dt.Rows[0][0].ToString()), InternetConnection.GetBusinessID(), InternetConnection.GetBusinessCode());
                    Thread.Sleep(3000);
                }
                else
                {
                    //update isConnected value to 0 in sales_master table where isConnected Value happened to be 1 recently
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand cmd     = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Master", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            });
            threadSales.Start();
            threadSales.IsBackground = true;

            #region lll
            //    foreach (ListViewItem item in listView1.Items)
            //    {
            //        DataTable dt = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");

            //        //Stopwatch stopwatch = new Stopwatch();
            //        //stopwatch.Start();
            //        Task t1 = Task.Factory.StartNew(() =>
            //        {

            //            ConnectionClass.InsertCommand("insert into Sales_Details " +
            //            " values ('" +
            //               item.SubItems[0].Text + "','" +
            //               item.SubItems[1].Text + "','" +
            //               item.SubItems[2].Text + "','" +
            //               item.SubItems[3].Text + "','" +
            //               item.SubItems[4].Text + "','" +
            //               dt.Rows[0][0].ToString() + "','True')");
            //        });
            //    }//end foreach

            //    if (InternetConnection.IsConnectedToInternet() && InternetConnection.CheckServerConnectivity(serverIP) == true)
            //    {

            //                 foreach (ListViewItem item in listView1.Items)
            //    {
            //        DataTable dt = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");
            //                   OnlineActivities.SendOnlineSalesDetail(Convert.ToInt64(item.SubItems[0].Text), item.SubItems[1].Text.ToString()
            //           , Convert.ToInt32(item.SubItems[2].Text),
            //           Convert.ToDecimal(item.SubItems[3].Text),
            //           Convert.ToDecimal(item.SubItems[4].Text),
            //           Convert.ToInt64(dt.Rows[0][0].ToString()),
            //           InternetConnection.GetBusinessID(), InternetConnection.GetBusinessCode());
            //            }

            //}//end if
            //else
            //{
            //    foreach (ListViewItem item in listView1.Items)
            //    {
            //        DataTable dt = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");
            //        ConnectionClass.InsertCommand("insert into Sales_Details " +
            //       " values ('" +
            //          item.SubItems[0].Text + "','" +
            //          item.SubItems[1].Text + "','" +
            //          item.SubItems[2].Text + "','" +
            //          item.SubItems[3].Text + "','" +
            //          item.SubItems[4].Text + "','" +
            //          dt.Rows[0][0].ToString() + "','True')");
            //        lblResponse.Text += "\nSales Detial Data Transfer Fails!";
            //    }//end foreach
            //    PrintReport();
            //}//end else
            #endregion

            #region internet status check was checked per item

            //detail list for transfer
            List <SalesDetail> salesDetailLst = new List <SalesDetail>();

            foreach (var item in salesDetailLstLocal)
            {
                DataTable   dt          = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");
                SalesDetail salesDetail = new SalesDetail();
                salesDetail.ProductID          = item.ProductID;
                salesDetail.ProductName        = item.ProductName;
                salesDetail.Quantity           = item.Quantity;
                salesDetail.UnitPrice          = item.UnitPrice;
                salesDetail.TotalPrice         = item.TotalPrice;
                salesDetail.SalesMasterIDLocal = Convert.ToInt64(dt.Rows[0][0].ToString());
                salesDetailLst.Add(salesDetail);
            }
            //  MessageBox.Show(WebAPIResource.statusCodes);
            // lblHttpResponse.Text += WebAPIResource.statusCodes.ToString();
            // List<SalesDetail> salesDetailList = new List<SalesDetail>();
            Thread t1 = new Thread(() =>
            {
                if (InternetConnection.IsConnectedToInternet())
                {
                    foreach (var item in salesDetailLst)
                    {
                        SalesDetail salesDetail = new SalesDetail();
                        DataTable dt            = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");
                        ConnectionClass.InsertCommand("insert into Sales_Details " +
                                                      " values ('" +
                                                      item.ProductID + "','" +
                                                      item.ProductName + "','" +
                                                      item.Quantity + "','" +
                                                      item.UnitPrice + "','" +
                                                      item.TotalPrice + "','" +
                                                      dt.Rows[0][0].ToString() + "','True')");
                    }
                }
                else
                {
                    foreach (var item in salesDetailLst)
                    {
                        SalesDetail salesDetail = new SalesDetail();
                        DataTable dt            = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");
                        ConnectionClass.InsertCommand("insert into Sales_Details " +
                                                      " values ('" +
                                                      item.ProductID + "','" +
                                                      item.ProductName + "','" +
                                                      item.Quantity + "','" +
                                                      item.UnitPrice + "','" +
                                                      item.TotalPrice + "','" +
                                                      dt.Rows[0][0].ToString() + "','False')");
                    }
                    /// PrintReport();
                    ////ClearItems();
                    //  lblHttpResponse.Text += "not connected!";
                }
            });
            t1.Start();
            t1.IsBackground = true;
            t1.Join();
            //PrintReport();


            ////Thread t2 = new Thread(() =>
            ////{
            ////    PrintReport();

            ////});
            ////t2.Start();
            ////t2.Join();
            Thread t3 = new Thread(() =>
            {
                if (InternetConnection.IsConnectedToInternet())
                {
                    foreach (var item in salesDetailLst)
                    {
                        OnlineActivities.SendOnlineSalesDetail(item.ProductID, item.ProductName,
                                                               Convert.ToInt32(item.Quantity), item.UnitPrice, item.TotalPrice,
                                                               item.SalesMasterIDLocal,
                                                               InternetConnection.GetBusinessID(),
                                                               InternetConnection.GetBusinessCode());
                    }
                }
                else
                {
                    //update isconnected value to 0 in sales_details table where isConnected is equal to 1 recently
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand cmd     = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Details", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    //   lblHttpResponse.Text += "not connected to internet";
                }
            });
            t3.Start();
            t3.IsBackground = true;
            #endregion
            #region original
            //foreach (ListViewItem item in listView1.Items)
            //{
            //    if (InternetConnection.IsConnectedToInternet() && InternetConnection.CheckServerConnectivity(serverIP) == true)
            //    {
            //        DataTable dt = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");

            //        //Stopwatch stopwatch = new Stopwatch();
            //        //stopwatch.Start();
            //        Task t1 = Task.Factory.StartNew(() =>
            //        {

            //            ConnectionClass.InsertCommand("insert into Sales_Details " +
            //            " values ('" +
            //               item.SubItems[0].Text + "','" +
            //               item.SubItems[1].Text + "','" +
            //               item.SubItems[2].Text + "','" +
            //               item.SubItems[3].Text + "','" +
            //               item.SubItems[4].Text + "','" +
            //               dt.Rows[0][0].ToString() + "','True')");
            //        });



            //        //stopwatch.Stop();
            //        ////long ts = stopwatch.Elapsed.Seconds;
            //        ////lblTimeElapsed.Text = ts.ToString();
            //        Task t2 = t1.ContinueWith(antTask =>
            //        {


            //            OnlineActivities.SendOnlineSalesDetail(Convert.ToInt64(item.SubItems[0].Text), item.SubItems[1].Text.ToString()
            //               , Convert.ToInt32(item.SubItems[2].Text),
            //               Convert.ToDecimal(item.SubItems[3].Text),
            //               Convert.ToDecimal(item.SubItems[4].Text),
            //               Convert.ToInt64(dt.Rows[0][0].ToString()),
            //               InternetConnection.GetBusinessID(), InternetConnection.GetBusinessCode()

            //               );
            //        });

            //    }

            //    else
            //    {
            //        DataTable dt = ConnectionClass.Selectcommand("select max(salesMasterID) from Sales_Master");
            //        ConnectionClass.InsertCommand("insert into Sales_Details " +
            //       " values ('" +
            //          item.SubItems[0].Text + "','" +
            //          item.SubItems[1].Text + "','" +
            //          item.SubItems[2].Text + "','" +
            //          item.SubItems[3].Text + "','" +
            //          item.SubItems[4].Text + "','" +
            //          dt.Rows[0][0].ToString() + "','True')");
            //        lblResponse.Text += "\nSales Detial Data Transfer Fails!";

            //    }
            //}
            #endregion
        }
Esempio n. 6
0
 private void Form1_Load(object sender, EventArgs e)
 {
     dataGridView1.DataSource = ConnectionClass.Selectcommand("select * from Category");
 }
Esempio n. 7
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable dt = ConnectionClass.Selectcommand("select Category_id from Category where CategoryName='" + comboBox1.Text + "'");

            pid = dt.Rows[0][0].ToString();
        }
Esempio n. 8
0
 private void Form1_Load(object sender, EventArgs e)
 {
     dataGridView1.DataSource = ConnectionClass.Selectcommand("select Productid,ProductName,CostPrice,SalePrice,description from product");
 }
Esempio n. 9
0
        // foreach( ){}

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView2.DataSource = ConnectionClass.Selectcommand("select * from sales_details where salesMaster_id='" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString() + "'");
        }
Esempio n. 10
0
 private void BoardReg_Load(object sender, EventArgs e)
 {
     dataGridView1.DataSource = ConnectionClass.Selectcommand("select * from sales_Master");
     calculation();
 }
Esempio n. 11
0
 private void DTIssuingDate_ValueChanged(object sender, EventArgs e)
 {
     param = "Sales List for Date Between " + DTP1.Text + " and " + DTP2.Text;
     dataGridView1.DataSource = ConnectionClass.Selectcommand("select * from sales_Master where Salesdate between '" + DTP1.Text + "' and '" + DTP2.Text + "'");
     calculation();
 }
Esempio n. 12
0
 private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
 {
     dataGridView1.DataSource = ConnectionClass.Selectcommand("select * from sales_Master where Salesdate between '" + DTP1.Text + "' and '" + DTP2.Text + "'");
     calculation();
 }