Ejemplo n.º 1
0
        //
        //----------------------------Cau hinh------------------------------------
        //

        private void cấuHìnhGiáToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tap_color();
            pnHome.Visible    = false;
            pnDanhmuc.Visible = false;
            pnQuanly.Visible  = false;
            pnThongke.Visible = false;
            pnLs.Visible      = false;
            pnCauhinh.Visible = true;

            F_Cauhinh f = new F_Cauhinh();

            f.ShowDialog();
            tb_cauhinh.Rows.Clear();
            data_tb("tb_cauhinh.txt", tb_cauhinh);
            foreach (Panel panel in l_khoi)
            {
                pnBang1.Controls.Remove(panel);
            }

            // cauhinh();
            pnHome.Visible = true;
        }
Ejemplo n.º 2
0
        // đồng ý nhập xuất

        private void Bt_Save_ls_Click(object sender, EventArgs e)
        {
            int checkdung = 0;
            int checksvt = 0, checksl2 = 0;
            int indexsai = -1;

            for (int i = 0; i < tb_ds_dachon.Rows.Count; i++)
            {
                if (tb_ds_dachon.Rows[i][2].ToString().Trim() != "0" && tb_ds_dachon.Rows[i][3].ToString() != "")
                {
                    checkdung++;
                }
                else
                {
                    checkdung = 0;
                    if (tb_ds_dachon.Rows[i][3].ToString().Trim() == "")
                    {
                        checksvt++; //  chưa chọn vị trí
                        indexsai = i;
                    }
                    if (tb_ds_dachon.Rows[i][2].ToString().Trim() == "0")
                    {
                        checksl2++; //  chưa chọn số lượng
                        indexsai = i;
                    }
                    break;
                }
            }

            if (checkdung != 0)
            {
                save_danhmuc();
                save_hientai();
                save_ls();

                F_Cauhinh.tool_save_txt(Form1.tb_ls, "ls.txt");           // lưu lịch sử vào file txt
                F_Cauhinh.tool_save_txt(Form1.tb_danhmuc, "danhmuc.txt"); // lưu lịch sử vào file txt
                F_Cauhinh.tool_save_txt(Form1.tb_hientai, "hientai.txt"); // lưu lịch sử vào file txt
                // xóa dữ liệu
                for (int i = l_pds.Count - 1; i >= 0; i--)
                {
                    pn_Giohang.Controls.RemoveAt(i);
                }
                l_pds.Clear();
                l_ds.Clear();
                tb_ds_dachon.Rows.Clear();
            }
            else
            {
                if (checksvt != 0)
                {
                    MessageBox.Show("Vui lòng chọn vị trí để " + lbTile.Text + " ''" + tb_ds_dachon.Rows[indexsai][1].ToString() + "''.", "Thông báo:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (checksl2 != 0)
                {
                    MessageBox.Show("Vui lòng chọn số lượng để " + lbTile.Text + " ''" + tb_ds_dachon.Rows[indexsai][1].ToString() + "''.", "Thông báo:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }


            show_nhap_xuat();
        }
Ejemplo n.º 3
0
        // đồng ý nhập xuất

        private void Bt_Save_ls_Click(object sender, EventArgs e)
        {
            // đồng ý để nhập xuất

            /*
             * - lưu danh sách vào bảng lịch sử nhập xuất => show lên data grid view lịch sử  nhập xuất(thêm số người nhập/ xuất)
             * - link danh sách vào bảng hiện tại cũng như bảng danh mục(số lượng)
             */

            // bảng lịch sử nhập xuất: Form1.tb_ls_nx
            // lưu vào tb_ls
            for (int i = 0; i < tb_ds_dachon.Rows.Count; i++)
            {
                for (int j = 0; j < Form1.tb_danhmuc.Rows.Count; j++)
                {
                    if (tb_ds_dachon.Rows[i][0].ToString().Trim() == Form1.tb_danhmuc.Rows[j][0].ToString().Trim())
                    {
                        // tb_ls
                        Form1.tb_ls.Rows.Add(
                            DateTime.Now.ToShortDateString(),  // ngày
                            tb_ds_dachon.Rows[i][4],           // giao dịch
                            tb_ds_dachon.Rows[i][0],           // mã sách
                            tb_ds_dachon.Rows[i][1],           // tên sách
                            Form1.tb_danhmuc.Rows[j][2],       // tác giả
                            Form1.tb_danhmuc.Rows[j][3],       // thể loại
                            Form1.tb_danhmuc.Rows[j][4],       // số trang
                            tb_ds_dachon.Rows[i][2],           // số lượng
                            tb_ds_dachon.Rows[i][3],           // vị trí
                            Form1.tb_danhmuc.Rows[j][7],       // NXB
                            lb_Acount.Text,                    // PIC
                            Form1.tb_danhmuc.Rows[j][8]        // ghi chú
                            );
                        // tb_hien tai
                    }
                }
            }



            //// lưu vào bảng danh mục và bảng hiện tại
            ///
            for (int i = 0; i < tb_ds_dachon.Rows.Count; i++)
            {
                string ma_dachon = tb_ds_dachon.Rows[i][0].ToString().Trim();
                for (int k = 0; k < Form1.tb_hientai.Rows.Count; k++)
                {
                    string ma_hientai = Form1.tb_hientai.Rows[k][0].ToString().Trim();
                    MessageBox.Show(ma_dachon + "\n" + ma_hientai);
                    if (ma_hientai == ma_dachon)    // đã tồn tại
                    {
                        int sl = Convert.ToInt32(tb_ds_dachon.Rows[i][2].ToString()) + Convert.ToInt32(Form1.tb_hientai.Rows[k][5].ToString());
                        MessageBox.Show(sl.ToString());
                        Form1.tb_hientai.Rows[k][5] = sl;

                        break;
                    }

                    else // chưa tồn tại
                    {
                        int    sl = Convert.ToInt32(tb_ds_dachon.Rows[i][2].ToString());
                        string vt = tb_ds_dachon.Rows[i][3].ToString();
                        for (int j = 0; j < Form1.tb_danhmuc.Rows.Count; j++)
                        {
                            if (tb_ds_dachon.Rows[i][0].ToString().Trim() == Form1.tb_danhmuc.Rows[j][0].ToString().Trim())
                            {
                                Form1.tb_hientai.Rows.Add(
                                    tb_ds_dachon.Rows[i][0],             // mã sách
                                    tb_ds_dachon.Rows[i][1],             // tên sách
                                    Form1.tb_danhmuc.Rows[j][2],         // tác giả
                                    Form1.tb_danhmuc.Rows[j][3],         // thể loại
                                    Form1.tb_danhmuc.Rows[j][4],         // số trang
                                    sl.ToString(),                       // số lượng
                                    tb_ds_dachon.Rows[i][3],             // vị trí
                                    Form1.tb_danhmuc.Rows[j][7],         // NXB
                                    Form1.tb_danhmuc.Rows[j][8]          // ghi chú
                                    );
                            }
                        }
                        break;
                    }
                }
            }



            //for (int i = 0; i < tb_ds_dachon.Rows.Count; i++)
            //{
            //    string ma_chon = tb_ds_dachon.Rows[i][0].ToString();

            //    // khác tên
            //    int sl = 0;
            //    string vt = "";
            //    for (int k = 0; k < Form1.tb_hientai.Rows.Count; k++)
            //    {
            //        string ma_hientai = Form1.tb_hientai.Rows[k][0].ToString().Trim();
            //        if (ma_chon != ma_hientai) // chưa tồn tại
            //        {
            //            sl = Convert.ToInt32(tb_ds_dachon.Rows[i][2].ToString());
            //            vt = tb_ds_dachon.Rows[i][3].ToString();
            //        }
            //        else // đã tồn tại
            //        {
            //            sl = Convert.ToInt32(tb_ds_dachon.Rows[i][2].ToString()) + Convert.ToInt32(Form1.tb_hientai.Rows[i][5].ToString());
            //            vt = Form1.tb_hientai.Rows[i][6].ToString();
            //        }
            //    }

            //    // add hàng
            //    for (int j = 0; j < Form1.tb_danhmuc.Rows.Count; j++)
            //    {
            //        if (tb_ds_dachon.Rows[i][0].ToString().Trim() == Form1.tb_danhmuc.Rows[j][0].ToString().Trim())
            //        {
            //            Form1.tb_hientai.Rows.Add(
            //              tb_ds_dachon.Rows[i][0], // mã sách
            //              tb_ds_dachon.Rows[i][1], // tên sách
            //              Form1.tb_danhmuc.Rows[j][2],  // tác giả
            //              Form1.tb_danhmuc.Rows[j][3],  // thể loại
            //              Form1.tb_danhmuc.Rows[j][4],  // số trang
            //              sl.ToString(), // số lượng
            //              tb_ds_dachon.Rows[i][3],  // vị trí
            //              Form1.tb_danhmuc.Rows[j][7], // NXB
            //              Form1.tb_danhmuc.Rows[j][8] // ghi chú
            //              );
            //        }
            //    }
            //}
            //Nhập

            //Xuất



            // show dữ liệu kiểm tra

            F_Cauhinh.tool_save_txt(Form1.tb_ls, "ls.txt"); // lưu lịch sử vào file txt
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = Form1.tb_hientai;



            // xóa stt_ds;
            // xóa bảng chọn
            tb_ds_dachon.Rows.Clear();
            // xóa panle
            for (int i = 0; i < l_pds.Count; i++)
            {
                pn_Giohang.Controls.Remove(l_pds[i]);
            }
        }