예제 #1
0
        private void sell_Click(object sender, EventArgs e)
        {
            int  q = 1;
            int  n;
            bool isNumeric = int.TryParse(quantityT.Text, out n);

            if (isNumeric && Convert.ToInt32(quantityT.Text) > 1 && quantityT.Text != "")
            {
                q = Convert.ToInt32(quantityT.Text);
            }
            quantityT.Text = "";
            if (P.id != -1 && P.quantity >= q)
            {
                id_q x = new id_q();
                x.id = P.id;
                x.q  = P.quantity - q;
                bool notExist = true;
                for (int i = 0; i < idq.Count; i++)
                {
                    if (x.id == idq[i].id)
                    {
                        idq[i].q = x.q;
                    }
                    notExist = false;
                }
                if (notExist = true)
                {
                    idq.Add(x);
                }
                double   totalPrice = Convert.ToDouble(pL.Text) * q;
                string[] row        = new string[] { P.id.ToString(), P.name, q.ToString(), totalPrice.ToString() };
                repGV.Rows.Add(row);
                P.id           = -1;
                P.color        = "";
                P.size         = "";
                P.quantity     = 0;
                P.price        = 0;
                P.actPrice     = 0;
                P.soldQuantity = 0;
                pL.Text        = "00.00";
                qL.Text        = "0";
                P.barcode      = "";
                P.name         = nameT.Text;
                P.serial       = serialT.Text;
                sizeLB.Items.Clear();
                colorLB.Items.Clear();
                userGV.DataSource = P.nameNumSelect();
            }
            double totalP = 0;

            for (int i = 0; i < repGV.Rows.Count; i++)
            {
                totalP += Convert.ToDouble(repGV.Rows[i].Cells[3].Value);
            }
            totalPL.Text = totalP.ToString();
        }
예제 #2
0
        private void handleTypingTimerTimeout(object sender, EventArgs e)
        {
            var timer = sender as Timer; // WinForms

            // var timer = sender as DispatcherTimer; // WPF
            if (timer == null)
            {
                return;
            }

            // Testing - updates window title
            string isbn = timer.Tag.ToString();

            barcodeT.Text = isbn; // WinForms
                                  // windowFrame.Title = isbn; // WPF
            if (barcodeT.Text != "")
            {
                if (P.SelectBarcode(barcodeT.Text) == true)
                {
                    P.productSelect();
                    for (int i = 0; i < idq.Count; i++)
                    {
                        if (P.id == idq[i].id)
                        {
                            P.quantity = idq[i].q;
                        }
                    }
                    pL.Text = P.price.ToString();
                    qL.Text = P.quantity.ToString();

                    int  q = 1;
                    int  n;
                    bool isNumeric = int.TryParse(quantityT.Text, out n);
                    if (isNumeric && Convert.ToInt32(quantityT.Text) > 1 && quantityT.Text != "")
                    {
                        q = Convert.ToInt32(quantityT.Text);
                    }
                    quantityT.Text = "";
                    if (P.id != -1 && P.quantity >= q)
                    {
                        id_q x = new id_q();
                        x.id = P.id;
                        x.q  = P.quantity - q;
                        bool notExist = true;
                        for (int i = 0; i < idq.Count; i++)
                        {
                            if (x.id == idq[i].id)
                            {
                                idq[i].q = x.q;
                            }
                            notExist = false;
                        }
                        if (notExist = true)
                        {
                            idq.Add(x);
                        }
                        double   totalPrice = Convert.ToDouble(pL.Text) * q;
                        string[] row        = new string[] { P.id.ToString(), P.name, q.ToString(), totalPrice.ToString() };
                        repGV.Rows.Add(row);
                        P.id           = -1;
                        P.color        = "";
                        P.size         = "";
                        P.quantity     = 0;
                        P.price        = 0;
                        P.actPrice     = 0;
                        P.soldQuantity = 0;
                        pL.Text        = "00.00";
                        qL.Text        = "0";
                        P.barcode      = "";
                        P.name         = nameT.Text;
                        P.serial       = serialT.Text;
                        sizeLB.Items.Clear();
                        colorLB.Items.Clear();
                        userGV.DataSource = P.nameNumSelect();
                    }
                    double totalP = 0;
                    for (int i = 0; i < repGV.Rows.Count; i++)
                    {
                        totalP += Convert.ToDouble(repGV.Rows[i].Cells[3].Value);
                    }
                    totalPL.Text = totalP.ToString();

                    barcodeT.Text = "";
                    P.barcode     = "";
                }
            }
            // The timer must be stopped! We want to act only once per keystroke.
            timer.Stop();
        }