Esempio n. 1
0
        private void btt_luu_Click(object sender, EventArgs e)
        {
            //Khai bao cac bien lay du lieu nhap tu form
            String ma  = txt_maspdv.Text.Trim();
            String ten = txt_tenspdv.Text.Trim();
            String dvt = txt_dvt.Text.Trim();

            //Khai bao chuoi sql
            String sql = "";

            if (flag == true)
            {
                sql += "Insert into spdv Values(N'" + ma + "',N'" + ten + "',N'" + dvt + "')";
            }
            else
            {
                sql += "Update spdv Set tenspdv=N'" + ten + "', dvt=N'" + dvt + "' where maspdv=N'" + ma + "'";
                flag = true;
            }

            //Kiem tra trang lai button Luu
            if (lib.execSQL(sql) == true)
            {
                HienThiSPDV();
                txt_maspdv.Enabled = true;
                XoaDuLieuTrenForm();
                flag = true;
            }
            else
            {
                MessageBox.Show("Lưu không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void btt_luu_Click(object sender, EventArgs e)
        {
            //Khai bao cac bien lay du lieu nhap tu form
            String ma        = txt_makh.Text.Trim();
            String ten       = txt_tenkh.Text.Trim();
            String dienthoai = txt_sdt.Text.Trim();
            String dc        = txt_diachi.Text.Trim();

            //Khai bao chuoi sql
            String sql = "";

            if (flag == true)
            {
                sql += "Insert into khachhang(tenkh, sdt, diachi) output inserted.makh Values(N'" + ten + "',";
                sql += "N'" + dienthoai + "',N'" + dc + "')";
            }
            else
            {
                sql += "Update khachhang Set tenkh=N'" + ten + "', SDT=N'" + dienthoai + "', diachi=N'" + dc + "' ";
                sql += "Where MAKH='" + ma + "'";
            }

            //Kiem tra trang lai button Luu
            if (lib.execSQL(sql) == true)
            {
                HienThiKhachHang();
                XoaDuLieuTrenForm();
                txt_makh.Enabled = true;
                flag             = true;
            }
            else
            {
                MessageBox.Show("Lưu không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        private void cbbThanhToan_Click(object sender, EventArgs e)
        {
            if (dgvSanPham.Rows.Count - 1 > 0)
            {
                bool     flag      = true;
                String   khachHang = txt_kh.Text.ToString();
                String   nhanVien  = cbb_nv.SelectedValue.ToString();
                DateTime nlhd      = Convert.ToDateTime(txtNgayLapHD.Text.Trim());
                String   ngaylhd   = String.Format("{0:MM/dd/yyyy}", nlhd);
                String   sqlHD     = "Insert into HOADON(maphieu, MANV, NGaylapHD) Values('" + txt_map.Text + "','" + nhanVien + "','" + ngaylhd + "') ";
                sqlHD += "update xuly set ghichu=N'X' where maphieu='" + txt_map.Text + "' and matt=N'SSTK' and ghichu=N'' insert into xuly(maphieu,manv,matt,thoigian,ghichu) output inserted.maxl values(N'" + txt_map.Text + "', N'" + lbnvdn.Text + "',N'HT','" + ngaylhd + "',N'')";

                if (lib.execSQL(sqlHD) == false)
                {
                    MessageBox.Show("Lập hóa đơn không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    flag = false;
                }
                else
                {
                    flag = true;
                    String sqlLayMaHD = "SELECT MAX(maHD) as sohd FROM HOADON";
                    String maHD       = lib.reDataSet(sqlLayMaHD).Tables[0].Rows[0]["soHD"].ToString();
                    for (int i = 0; i < dgvSanPham.Rows.Count - 1; i++)
                    {
                        String maSP = dgvSanPham.Rows[i].Cells[0].Value.ToString();
                        int    sl   = Convert.ToInt32(dgvSanPham.Rows[i].Cells[2].Value.ToString());
                        int    dg   = Convert.ToInt32(dgvSanPham.Rows[i].Cells[3].Value.ToString());

                        String sqlCTHD = "Insert into chitiethd Values('" + maHD + "',N'" + maSP + "','" + sl + "','" + dg + "')";

                        lib.execSQL(sqlCTHD);
                    }
                }

                if (flag == true)
                {
                    String       sqlLayMaHD = "SELECT MAX(maHD) AS SOHD FROM HOADON";
                    String       ma_HD      = lib.reDataSet(sqlLayMaHD).Tables[0].Rows[0]["SOHD"].ToString();
                    frm_inhoadon fInHoaDon  = new frm_inhoadon(ma_HD);
                    fInHoaDon.Show();
                    hienthisstrak();
                }
                else
                {
                    MessageBox.Show("Lap hoa don khong thanh cong.", "QLBH", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Chua co san pham.", "QLBH", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbbThemSP.Focus();
            }
        }
Esempio n. 4
0
        private void btt_luu_Click(object sender, EventArgs e)
        {
            String   mp      = txt_maphieu.Text.Trim();
            String   makh    = cbb_makh.SelectedValue.ToString();
            String   seri    = txt_seri.Text.Trim();
            String   tensp   = txt_ten.Text.Trim();
            String   yeucau  = txt_yeucau.Text.Trim();
            String   ghichu  = txt_ghichu.Text.Trim();
            DateTime nht     = Convert.ToDateTime(dtp_hentra.Text.Trim());
            String   ngayht  = String.Format("{0:MM/dd/yyyy}", nht);
            DateTime nnhs    = DateTime.Today;
            String   ngaynhs = String.Format("{0:MM/dd/yyyy}", nnhs);
            String   manv    = lb_manv.Text;

            String sql = "";

            if (flag == true)
            {
                sql += "insert into phieunhan(makh,serisp,tensp,yeucaukh,ghichu,manv,ngayhentra,ngaynhanhs) output inserted.maphieu ";
                sql += "values('" + makh + "',N'" + seri + "',N'" + tensp + "',N'" + yeucau + "',N'" + ghichu + "',N'" + manv + "','" + ngayht + "','" + ngaynhs + "') ";
                sql += "insert into xuly(maphieu,manv,matt,thoigian,ghichu) output inserted.maxl values((select max(maphieu) from phieunhan), N'" + manv + "',N'DN','" + ngaynhs + "',N'')";
            }
            else
            {
                sql += "update phieunhan set serisp=N'" + seri + "',tensp=N'" + tensp + "',yeucaukh=N'" + yeucau + "',ngayhentra='" + ngayht + "',ghichu=N'" + ghichu + "' where maphieu='" + mp + "'";
            }
            if (lib.execSQL(sql) == true)
            {
                hienthiphieunhan();
                xoadulieutrenform();
                cbb_makh.Enabled = true;
                if (flag == true)
                {
                    frm_in_phieunhan IN = new frm_in_phieunhan();
                    IN.Show();
                }
                else
                {
                    flag = true;
                }
            }
            else
            {
                MessageBox.Show("Lưu không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
 private void dgv_pnchuaxl_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 10)
     {
         String   sql    = "";
         String   manv   = lbmanvdn.Text;
         String   mp     = dgv_pnchuaxl.CurrentRow.Cells[1].Value.ToString();
         DateTime nxl    = DateTime.Today;
         String   ngayxl = String.Format("{0:MM/dd/yyyy}", nxl);
         sql += "update xuly set ghichu=N'X' where maphieu='" + mp + "' and matt=N'DN' and ghichu=N'' insert into xuly(maphieu,manv,matt,thoigian,ghichu) output inserted.maxl values(N'" + mp + "', N'" + manv + "',N'KT','" + ngayxl + "',N'')";
         if (lib.execSQL(sql) == true)
         {
             hienthipnchoxl();
             hienthipndangkt();
             hienthisstrak();
         }
         else
         {
             MessageBox.Show("Xử lý hồ sơ không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 6
0
        private void btt_luu_Click(object sender, EventArgs e)
        {
            //Khai bao cac bien lay du lieu nhap tu form
            String   ma       = txt_ma.Text.Trim();
            String   ten      = txt_tennv.Text.Trim();
            String   chucvu   = cbb_chucvu.SelectedValue.ToString();
            String   sdt      = txt_sdtnv.Text.Trim();
            DateTime dt       = Convert.ToDateTime(dtp_namsinh.Text.Trim());
            String   ngaySinh = String.Format("{0:MM/dd/yyyy}", dt);
            String   dc       = txt_dcnv.Text.Trim();
            String   mk       = lib.cryMD5(ma);

            //Khai bao chuoi sql
            String sql = "";

            if (flag == true)
            {
                sql += "Insert into nhanvien Values(N'" + ma + "',N'" + ten + "',N'" + chucvu + "',N'" + sdt + "','" + ngaySinh + "',N'" + dc + "',N'" + mk + "')";
            }
            else
            {
                sql += "Update nhanvien Set tennv=N'" + ten + "',macv=N'" + chucvu + "',sdt=N'" + sdt + "',namsinh='" + ngaySinh + "',diachi=N'" + dc + "',matkhau=N'" + mk + "' where manv=N'" + ma + "'";
            }

            //Kiem tra trang lai button Luu
            if (lib.execSQL(sql) == true)
            {
                HienThiNhanVien();
                txt_ma.Enabled = true;
                XoaDuLieuTrenForm();
                flag = true;
            }
            else
            {
                MessageBox.Show("Lưu không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }