Ejemplo n.º 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     ConnectionClass.UpdateCommand("update product set BusinessTypeName='" + BusinessName.Text + "',Description='" + Description.Text + "' where  BusinessType_ID='" + pidM + "'");
     MessageBox.Show("Successfully Added");
     dgv.DataSource = ConnectionClass.Selectcommand("select * from Product");
     this.Close();
 }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt = ConnectionClass.Selectcommand("select type from language");

            if (dt.Rows[0][0].ToString() == "English")
            {
                English();
            }
            else
            {
                Urdu();
            }


            DataTable dt1 = ConnectionClass.Selectcommand("select categoryName from Category");

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

            DataTable dt2 = ConnectionClass.Selectcommand("select ProductCode,ProductName,CostPrice,SalePrice,Description from Product where productid='" + pid + "'");

            ProductCode.Text = dt2.Rows[0][0].ToString();
            ProductName.Text = dt2.Rows[0][1].ToString();
            CostPrice.Text   = dt2.Rows[0][2].ToString();
            SalePrice.Text   = dt2.Rows[0][3].ToString();
            Description.Text = dt2.Rows[0][4].ToString();
        }
Ejemplo n.º 3
0
        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            DataTable dt = ConnectionClass.Selectcommand("select BusinessType_Id from Business_Type where BusinessTypeName='" + comboBox1.Text + "'");

            bid
                = dt.Rows[0][0].ToString();
        }
Ejemplo n.º 4
0
        void MouseClick2(object sender, EventArgs e)
        {
            Button    bt = (Button)sender;
            int       a  = 1;
            DataTable dt = ConnectionClass.Selectcommand("select ProductId,SalePrice from Product where ProductName='" + bt.Text + "'");

            foreach (ListViewItem item1 in listView1.Items)
            {
                if (dt.Rows[0][0].ToString() == item1.SubItems[0].Text.ToString())
                {
                    a = 0;
                    decimal qt = Convert.ToDecimal(item1.SubItems[2].Text.ToString());
                    decimal up = Convert.ToDecimal(item1.SubItems[3].Text.ToString());

                    qt += 1;
                    item1.SubItems[2].Text = qt.ToString();
                    item1.SubItems[4].Text = (up * qt).ToString();
                    calcuation();
                }
            }
            if (a == 1)
            {
                string[]     str  = { dt.Rows[0][0].ToString(), bt.Text, "1", dt.Rows[0][1].ToString(), dt.Rows[0][1].ToString() };
                ListViewItem item = new ListViewItem(str);

                listView1.Items.Insert(0, item);
                calcuation();
            }
        }
Ejemplo n.º 5
0
 public void language()
 {
     try
     {
         dt = ConnectionClass.Selectcommand("select type from language");
         if (dt.Rows[0][0].ToString() == "English")
         {
             //metroTextBox1.WaterMark = "Username";
             //metroTextBox2.WaterMark = "Password";
             //label1.Text = "Please Login to Continue";
             //metroTextBox1.TextAlign = HorizontalAlignment.Left;
             //metroTextBox2.TextAlign = HorizontalAlignment.Left;
             //materialRaisedButton1.Text = "Login";
             //groupBox1.Text = "Language";
             //metroRadioButton1.Checked = true;
         }
         else
         {
             //metroTextBox1.WaterMark = "صارف کا نام";
             //metroTextBox2.WaterMark = "پاس ورڈ";
             //label1.Text = "جاری رکھنے کے لئے لاگ ان کریں";
             //metroTextBox1.TextAlign = HorizontalAlignment.Right;
             //metroTextBox2.TextAlign = HorizontalAlignment.Right;
             //materialRaisedButton1.Text = "لاگ ان";
             //groupBox1.Text = "زبان";
             //metroRadioButton2.Checked = true;
         }
     }
     catch { }
 }
Ejemplo n.º 6
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = ConnectionClass.Selectcommand("Select * from Login where Username = '******' and Password='******' ");
         if (dt.Rows.Count > 0)
         {
             string userType = dt.Rows[0][1].ToString();
             if (userType == "Admin" || userType == "admin")
             {
                 AdminHome obj = new AdminHome();
                 this.Hide();
                 obj.Show();
             }
             else
             {
                 Home2 obj = new Home2(dt.Rows[0][2].ToString());
                 this.Hide();
                 obj.Show();
             }
         }
         else
         {
             MessageBox.Show("Invalid username or password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch
     {
         MessageBox.Show("Server is not respondin!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 7
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (radioButton2.Checked = true)
            {
                try
                {
                    DataTable dt = ConnectionClass.Selectcommand("select max(id) from Category");

                    int sno = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1;
                    ConnectionClass.InsertCommand("insert into Category Values('" + sno + "','','" + metroTextBox1.Text + "','','','" + pid + "')");
                }
                catch
                {
                    ConnectionClass.InsertCommand("insert into Category Values('1','','" + metroTextBox1.Text + "','','','" + pid + "')");
                }
                MessageBox.Show("Sucessfully Added !", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                metroTextBox1.Text = "";
            }
            else
            {
                try
                {
                    DataTable dt = ConnectionClass.Selectcommand("select max(sno) from Category");

                    int sno = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1;
                    ConnectionClass.InsertCommand("insert into Category Values('" + sno + "','','" + metroTextBox1.Text + "','','','')");
                }
                catch
                {
                    ConnectionClass.InsertCommand("insert into Category Values('1','','" + metroTextBox1.Text + "','','','')");
                }
            }
            MessageBox.Show("Successfully Message", "Successfully Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
            metroTextBox1.Text = "";
        }
Ejemplo n.º 8
0
        private void button3_Click(object sender, EventArgs e)
        {
            ConnectionClass.UpdateCommand("update product set ProductCode='" + ProductCode.Text + "',ProductName='" + ProductName.Text + "',CostPrice='" + CostPrice.Text + "',SalePrice='" + SalePrice.Text + "',Description='" + Description.Text + "' where productid='" + pid + "'");
            MessageBox.Show("Sucessfully Added !", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

            dgv.DataSource = ConnectionClass.Selectcommand("select * from Product");
            this.Close();
        }
Ejemplo n.º 9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt2 = ConnectionClass.Selectcommand("select BusinessTypeName,Description from Business_type where BusinessType_ID='" + pidM + "'");

            BusinessName.Text = dt2.Rows[0][0].ToString();

            Description.Text = dt2.Rows[0][1].ToString();
        }
Ejemplo n.º 10
0
 private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         dataGridView2.DataSource = ConnectionClass.Selectcommand("select * from sales_details where salesMaster_id='" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString() + "'");
     }
     catch { }
 }
Ejemplo n.º 11
0
        public void calculation()
        {
            DataTable dt = ConnectionClass.Selectcommand("select count(SalesMasterID),sum(TotalAmount),sum(SalesTax),sum(NetAmount) from Sales_Master");

            TotalInvoice.Text = dt.Rows[0][0].ToString();
            TotalSale.Text    = dt.Rows[0][1].ToString();
            TotalTax.Text     = dt.Rows[0][2].ToString();
            TotalReport.Text  = dt.Rows[0][3].ToString();
        }
Ejemplo n.º 12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt1 = ConnectionClass.Selectcommand("select CategoryName from Category");

            foreach (DataRow row in dt1.Rows)
            {
                comboBox1.Items.Add(row[0].ToString());
            }
        }
Ejemplo n.º 13
0
        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            DataTable dt = ConnectionClass.Selectcommand("select count(SalesMasterID),sum(TotalAmount),sum(SalesTax),sum(NetAmount) from Sales_Master where SalesDate between '" + dateTimePicker1.Text + "' and '" + dateTimePicker2.Text + "'");

            TotalInvoice.Text = dt.Rows[0][0].ToString();
            TotalSale.Text    = dt.Rows[0][1].ToString();
            TotalTax.Text     = dt.Rows[0][2].ToString();
            TotalReport.Text  = dt.Rows[0][3].ToString();
        }
Ejemplo n.º 14
0
        private void PrintReport()
        {
            DataTable      dt2 = ConnectionClass.Selectcommand("select max(salesMasterID) from sales_Master2");
            ReportDocument rd  = new KPRA_RIMS.Reports.Bill();

            rd.RecordSelectionFormula = "{sales_Master2.salesMasterID}=" + dt2.Rows[0][0].ToString();
            ReportViewer obj = new ReportViewer(rd);

            obj.ShowDialog();
        }
Ejemplo n.º 15
0
        public void delete()
        {
            DialogResult result = MessageBox.Show("Do you really want to Delete this Product", "Confirm product Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                ConnectionClass.DeleteCommand("Delete from Category where Category_id=" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
                MessageBox.Show("Account Deleted Successfully!");
                dataGridView1.DataSource = ConnectionClass.Selectcommand("select * from Category");
            }
        }
Ejemplo n.º 16
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = ConnectionClass.Selectcommand("select category_id from category where categoryName='" + comboBox1.Text + "'");

                ConnectionClass.InsertCommand("insert into Product values('" + dt.Rows[0][0].ToString() + "','" + ProductCode.Text + "','" + ProductName.Text + "','" + Description.Text + "','" + CostPrice.Text + "','" + SalePrice.Text + "')");
                MessageBox.Show("Sucessfully Added !", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ProductCode.Text = ProductName.Text = Description.Text = CostPrice.Text = SalePrice.Text = "";
            }
            catch { }
        }
Ejemplo n.º 17
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt = ConnectionClass.Selectcommand("select * from business");

            BusinessCode.Text  = dt.Rows[0][1].ToString();
            BusinessName.Text  = dt.Rows[0][2].ToString();
            metroTextBox1.Text = dt.Rows[0][3].ToString();
            Description.Text   = dt.Rows[0][4].ToString();
            Contact.Text       = dt.Rows[0][5].ToString();
            Email.Text         = dt.Rows[0][6].ToString();
            Address.Text       = dt.Rows[0][7].ToString();
        }
Ejemplo n.º 18
0
 private void Lbsuntotal_TextChanged(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = ConnectionClass.Selectcommand("select Tax from Tax");
         decimal   kp = ((Convert.ToDecimal(dt.Rows[0][0].ToString())) * Convert.ToDecimal(Lbsuntotal.Text)) / 100;
         LBKpra.Text = kp.ToString();
     }
     catch
     {
         LBKpra.Text = "0";
     }
 }
Ejemplo n.º 19
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt = ConnectionClass.Selectcommand("select type from language");

            if (dt.Rows[0][0].ToString() == "English")
            {
                English();
            }
            else
            {
                Urdu();
            }
        }
Ejemplo n.º 20
0
        private void TBPName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.P)
            {
                Keyboard obj = new Keyboard(LbPayable, TBPaid, button1);
                obj.Show();
            }
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    DataTable dt;
                    int       a = 1;
                    try
                    {
                        dt = ConnectionClass.Selectcommand("select ProductId,ProductName,SalePrice from Product where ProductName='" + TBPName.Text + "' or productid='" + TBPName.Text + "'");
                    }

                    catch {
                        dt = ConnectionClass.Selectcommand("select ProductId,ProductName,SalePrice from Product where ProductName='" + TBPName.Text + "'");
                    }

                    foreach (ListViewItem item1 in listView1.Items)
                    {
                        if (dt.Rows[0][0].ToString() == item1.SubItems[0].Text.ToString())
                        {
                            a = 0;
                            decimal qt = Convert.ToDecimal(item1.SubItems[2].Text.ToString());
                            decimal up = Convert.ToDecimal(item1.SubItems[3].Text.ToString());

                            qt += 1;
                            item1.SubItems[2].Text = qt.ToString();
                            item1.SubItems[4].Text = (up * qt).ToString();
                            calcuation();
                            TBPName.Text = "";
                        }
                    }
                    if (a == 1)
                    {
                        string[]     str  = { dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), "1", dt.Rows[0][2].ToString(), dt.Rows[0][2].ToString() };
                        ListViewItem item = new ListViewItem(str);

                        listView1.Items.Insert(0, item);
                        calcuation();
                        TBPName.Text = "";
                    }
                }
                catch { }
            }
        }
Ejemplo n.º 21
0
 private void metroTextBox2_TextChanged(object sender, EventArgs e)
 {
     try
     {
         B = 1;
         DataTable dt11 = ConnectionClass.Selectcommand("select ProductName from Product where ProductName like '%" + metroTextBox2.Text + "%'");
         flowLayoutPanel1.Controls.Clear();
         foreach (DataRow row in dt11.Rows)
         {
             AddNewSubButton(row[0].ToString());
         }
     }
     catch { }
 }
Ejemplo n.º 22
0
 private void metroTextBox1_TextChanged(object sender, EventArgs e)
 {
     try
     {
         B = 1;
         DataTable dt = ConnectionClass.Selectcommand("select CategoryName from Category where CategoryName like '%" + metroTextBox1.Text + "%'");
         panel3.Controls.Clear();
         foreach (DataRow row in dt.Rows)
         {
             AddNewButton(row[0].ToString());
         }
     }
     catch { }
 }
Ejemplo n.º 23
0
        public void autoCompleteMethod()
        {
            DataTable dt = ConnectionClass.Selectcommand("Select ProductName from Product");

            AutoCompleteStringCollection autoName = new AutoCompleteStringCollection();



            foreach (DataRow row in dt.Rows)
            {
                autoName.Add(row[0].ToString());
            }

            TBPName.AutoCompleteCustomSource = autoName;
        }
Ejemplo n.º 24
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = ConnectionClass.Selectcommand("select max(id) from Category");

                int sno = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1;
                ConnectionClass.InsertCommand("insert into Category Values('" + sno + "','','','" + metroTextBox1.Text + "','','" + pid + "')");
            }
            catch
            {
                ConnectionClass.InsertCommand("insert into Category Values('1','" + metroTextBox1.Text + "','" + pid + "')");
            }
            metroTextBox1.Text = "";
        }
Ejemplo n.º 25
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 { }
        }
Ejemplo n.º 26
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();
            }
        }
Ejemplo n.º 27
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());
            }
        }
Ejemplo n.º 28
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
        }
Ejemplo n.º 29
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();
        }
Ejemplo n.º 30
0
 private void Form1_Load(object sender, EventArgs e)
 {
     dataGridView1.DataSource = ConnectionClass.Selectcommand("select * from Category");
 }