Esempio n. 1
0
        private void btnPrintCooking_Click(object sender, EventArgs e)
        {
            if (iCurrentReceiptID >= 0)
            {
                int i;
                DataSetHoaDon dsBill = new DataSetHoaDon();
                DataSet dsSP = new DataAccess().getChitietHDXuatByID(iCurrentReceiptID);
                DataSet dsHD = new DataAccess().getHoadonxuatByIDHoadonXuat(iCurrentReceiptID);
                ChitietHDXuat obj = new ChitietHDXuat();

                for (i = 0; i < dsSP.Tables[0].Rows.Count; i++)
                {
                    if (Convert.ToBoolean(dsSP.Tables[0].Rows[i]["Bep"]) == false)
                    {
                        DataRow dr1 = dsBill.Tables["RDatadetail"].NewRow();
                        dr1["STT"] = (i + 1).ToString();
                        dr1["TenSanPham"] = dsSP.Tables[0].Rows[i]["TenSanPham"].ToString();
                        dr1["DVT"] = dsSP.Tables[0].Rows[i]["DVT"].ToString();
                        dr1["DonGia"] = dsSP.Tables[0].Rows[i]["Gia"].ToString();
                        dr1["Soluong"] = dsSP.Tables[0].Rows[i]["Soluong"].ToString();
                        dr1["ThanhTien"] = Convert.ToDecimal(dsSP.Tables[0].Rows[i]["Thanhtien"]).ToString("###,###,###,###");

                        dsBill.Tables["RDatadetail"].Rows.Add(dr1);

                    }
                }

                //read Company Information
                string strCompanyName = "";
                string strCompanyAddress = "";
                string strCompanyPhone = "";
                string strLoiChao1 = "";
                string strLoiChao2 = "";
                DataSet dsSetting = new DataAccess().getSettingByDate("");
                if (dsSetting != null)
                {
                    if (dsSetting.Tables[0].Rows.Count > 0)
                    {
                        if (!(dsSetting.Tables[0].Rows[0]["TenCT"] is DBNull))
                            strCompanyName = Convert.ToString(dsSetting.Tables[0].Rows[0]["TenCT"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Diachi"] is DBNull))
                            strCompanyAddress = Convert.ToString(dsSetting.Tables[0].Rows[0]["Diachi"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Phone"] is DBNull))
                            strCompanyPhone = Convert.ToString(dsSetting.Tables[0].Rows[0]["Phone"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Loichao1"] is DBNull))
                            strLoiChao1 = Convert.ToString(dsSetting.Tables[0].Rows[0]["Loichao1"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Loichao2"] is DBNull))
                            strLoiChao2 = Convert.ToString(dsSetting.Tables[0].Rows[0]["Loichao2"]);
                    }
                }

                DataRow dr = dsBill.Tables["HeaderData"].NewRow();
                dr["Ngayxuat"] = currentReceipt.Ngayxuat.ToString("dd/MM/yyyy HH:mm:ss tt");
                dr["Phong"] = "";
                dr["GiaPhong"] = "";
                dr["HoadonID"] = iCurrentReceiptID.ToString();
                dr["GioBD"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]).ToShortTimeString();
                dr["GioKT"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).ToShortTimeString();
                dr["Nhanvien"] = cboEmployee.Text;
                dr["Thue"] = numTax.Value.ToString();
                dr["Tiengiam"] = numExtra.Value.ToString();
                dr["Phuthu"] = numExtra.Value.ToString();
                dr["Tiengio"] = "";
                dr["Tienhang"] = txtProductMoney.Text;
                dr["Tongcong"] = txtBilltotal.Text;
                dr["Tratruoc"] = numDeposit.Value.ToString("###,###,##0");
                dr["Tralai"] = txtReturnMoney.Text;
                dr["TenCongTy"] = strCompanyName;
                dr["DiaChi"] = "ĐC: " + strCompanyAddress;
                dr["SoDT"] = "ĐT: " + strCompanyPhone;
                dr["Loichao1"] = strLoiChao1;
                dr["Loichao2"] = strLoiChao2;
                dsBill.Tables["HeaderData"].Rows.Add(dr);

                if (dsBill != null)
                {
                    //load last setting
                    DataSet ds = new DataAccess().getSettingByDate("");
                    string printer;
                    try
                    {
                        printer = Convert.ToString(ds.Tables[0].Rows[0]["MayInBep"]);
                        myPrinters.SetDefaultPrinter(printer);
                    }
                    catch
                    {
                        MessageBox.Show("Chưa cài đặt máy in!", "Thông báo");
                    }
                    frmViewReport frmView = new frmViewReport(dsBill, true);
                    if (frmView.ShowDialog() == DialogResult.Yes)
                    {
                        for (i = 0; i < dsSP.Tables[0].Rows.Count; i++)
                        {
                            if (Convert.ToBoolean(dsSP.Tables[0].Rows[i]["Bep"]) == false)
                            {
                                //update bep
                                obj.IDChitietHDXuat = Convert.ToInt32(dsSP.Tables[0].Rows[i]["IDChitietHDXuat"]);
                                obj.IDHoadonXuat = Convert.ToInt32(dsSP.Tables[0].Rows[i]["IDHoadonXuat"]);
                                obj.IDSanpham = Convert.ToInt32(dsSP.Tables[0].Rows[i]["IDSanpham"]);
                                obj.IDGiaxuat = Convert.ToInt32(dsSP.Tables[0].Rows[i]["IDGiaXuatSP"]);
                                obj.Soluong = Convert.ToInt32(dsSP.Tables[0].Rows[i]["Soluong"]);
                                obj.Kho = Convert.ToBoolean(dsSP.Tables[0].Rows[i]["Kho"]);
                                obj.Giam = Convert.ToInt32(dsSP.Tables[0].Rows[i]["Giam"]);
                                obj.Ghichu = Convert.ToString(dsSP.Tables[0].Rows[i]["Ghichu"]);
                                obj.Bep = true;
                                try
                                {
                                    if (new DataAccess().updateChitietHDXuat(obj) != true)
                                        MessageBox.Show("Lỗi dữ liệu", "Thông báo");
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
        }
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            if (iCurrentReceiptID >= 0)
            {
                int           i;
                DataSetHoaDon dsBill = new DataSetHoaDon();
                DataSet       dsSP   = new DataAccess().getChitietHDXuatByID(iCurrentReceiptID);
                DataSet       dsHD   = new DataAccess().getHoadonxuatByIDHoadonXuat(iCurrentReceiptID);


                for (i = 0; i < dsSP.Tables[0].Rows.Count; i++)
                {
                    DataRow dr1 = dsBill.Tables["RDatadetail"].NewRow();
                    dr1["STT"]        = (i + 1).ToString();
                    dr1["TenSanPham"] = dsSP.Tables[0].Rows[i]["TenSanPham"].ToString();
                    dr1["DVT"]        = dsSP.Tables[0].Rows[i]["DVT"].ToString();
                    dr1["DonGia"]     = dsSP.Tables[0].Rows[i]["Gia"].ToString();
                    dr1["Soluong"]    = dsSP.Tables[0].Rows[i]["Soluong"].ToString();
                    dr1["ThanhTien"]  = Convert.ToDecimal(dsSP.Tables[0].Rows[i]["Thanhtien"]).ToString("###,###,###,###");

                    dsBill.Tables["RDatadetail"].Rows.Add(dr1);
                }
                DataRow dr2 = dsBill.Tables["RDatadetail"].NewRow();
                dr2["STT"]        = (i + 2).ToString();
                dr2["TenSanPham"] = "Tiền phòng";
                dr2["DVT"]        = ("Giờ").ToString();
                dr2["DonGia"]     = txtRoomPrice.Text;
                TimeSpan ts = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).
                              TimeOfDay.Subtract(Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]).TimeOfDay);
                double playmin = ts.Hours + Convert.ToDouble(ts.Minutes) / 60;
                dr2["Soluong"]   = playmin.ToString("##.00");
                dr2["ThanhTien"] = txtHourMoney.Text;
                dsBill.Tables["RDatadetail"].Rows.Add(dr2);

                DataRow dr3 = dsBill.Tables["RDatadetail"].NewRow();
                dr3["STT"]        = (i + 3).ToString();
                dr3["TenSanPham"] = "Phụ thu";
                //dr3["DVT"] = ("").ToString();
                dr3["DonGia"]    = txtExtra.Text;
                dr3["Soluong"]   = "1";
                dr3["ThanhTien"] = txtExtra.Text;
                dsBill.Tables["RDatadetail"].Rows.Add(dr3);

                DataRow dr4 = dsBill.Tables["RDatadetail"].NewRow();
                dr4["STT"]        = (i + 4).ToString();
                dr4["TenSanPham"] = "Thuế";
                dr4["DVT"]        = ("%").ToString();
                // dr4["DonGia"] = "Phần Trăm";
                dr4["Soluong"] = txtTax.Text;
                if (txtBilltotal.Text == "")
                {
                    dr4["ThanhTien"] = "0";
                }
                else
                {
                    dr4["ThanhTien"] = (Convert.ToDouble(txtBilltotal.Text) * Convert.ToDouble(txtTax.Text) /
                                        (100 + Convert.ToDouble(txtTax.Text))).ToString("###,###,##0");
                }
                dsBill.Tables["RDatadetail"].Rows.Add(dr4);
                //read Company Information form file
                StreamReader reader            = null;
                string       strCompanyName    = "";
                string       strCompanyAddress = "";
                string       strCompanyPhone   = "";
                try
                {
                    reader = new StreamReader("COMConfig.txt");
                    while (!reader.EndOfStream)
                    {
                        string line       = reader.ReadLine();
                        int    indexEqual = line.IndexOf('=');
                        string title      = line.Substring(0, indexEqual);
                        string data       = line.Substring(indexEqual + 1, line.Length - indexEqual - 1);
                        switch (title)
                        {
                        case "[COMPORT]":
                            break;

                        case "[BAUDRATE]":
                            break;

                        case "[STOPBITS]":
                            break;

                        case "[PARITY]":
                            break;

                        case "[DATABITS]":
                            break;

                        case "[CompanyName]":
                            strCompanyName = Convert.ToString(data);
                            break;

                        case "[Address]":
                            strCompanyAddress = Convert.ToString(data);
                            break;

                        case "[Phone]":
                            strCompanyPhone = Convert.ToString(data);
                            break;

                        default:
                            break;
                        }
                    }
                    reader.Close();
                }
                catch
                {
                    MessageBox.Show("Thông tin trong file COMConfig.txt chưa đúng!. \nVui lòng cập nhật lại thông tin của file này!");
                }
                DataRow dr = dsBill.Tables["HeaderData"].NewRow();
                dr["Ngayxuat"]  = txtTime.Text;
                dr["Phong"]     = txtRoom.Text;
                dr["GiaPhong"]  = txtRoomPrice.Text;
                dr["HoadonID"]  = iCurrentReceiptID.ToString();
                dr["GioBD"]     = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]).ToShortTimeString();
                dr["GioKT"]     = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).ToShortTimeString();
                dr["Nhanvien"]  = cboEmployee.Text;
                dr["Thue"]      = txtTax.Text;
                dr["Tiengiam"]  = txtReduce.Text;
                dr["Phuthu"]    = txtExtra.Text;
                dr["Tiengio"]   = txtHourMoney.Text;
                dr["Tienhang"]  = txtProductMoney.Text;
                dr["Tongcong"]  = txtBilltotal.Text;
                dr["TenCongTy"] = strCompanyName;
                dr["DiaChi"]    = "ĐC: " + strCompanyAddress;
                dr["SoDT"]      = "ĐT: " + strCompanyPhone;
                dsBill.Tables["HeaderData"].Rows.Add(dr);

                if (dsBill != null)
                {
                    frmViewReport frmView = new frmViewReport(dsBill);
                    frmView.Show();
                }
            }
        }
Esempio n. 3
0
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            if (iCurrentReceiptID >= 0)
            {
                int i;
                DataSetHoaDon dsBill = new DataSetHoaDon();
                DataSet dsSP = new DataAccess().getChitietHDXuatByID(iCurrentReceiptID);
                DataSet dsHD = new DataAccess().getHoadonxuatByIDHoadonXuat(iCurrentReceiptID);

                for (i = 0; i < dsSP.Tables[0].Rows.Count; i++)
                {
                    DataRow dr1 = dsBill.Tables["RDatadetail"].NewRow();
                    dr1["STT"] = (i + 1).ToString();
                    dr1["TenSanPham"] = dsSP.Tables[0].Rows[i]["TenSanPham"].ToString();
                    dr1["DVT"] = dsSP.Tables[0].Rows[i]["DVT"].ToString();
                    dr1["DonGia"] = dsSP.Tables[0].Rows[i]["Gia"].ToString();
                    dr1["Giam"] = dsSP.Tables[0].Rows[i]["Giam"].ToString() + "%";
                    dr1["Soluong"] = dsSP.Tables[0].Rows[i]["Soluong"].ToString();
                    dr1["ThanhTien"] = Convert.ToDecimal(dsSP.Tables[0].Rows[i]["Thanhtien"]).ToString("###,###,###,###");

                    dsBill.Tables["RDatadetail"].Rows.Add(dr1);
                }

                DataRow dr3 = dsBill.Tables["RDatadetail"].NewRow();
                dr3["STT"] = (i + 3).ToString();
                dr3["TenSanPham"] = "Phụ thu";
                //dr3["DVT"] = ("").ToString();
                dr3["DonGia"] = numExtra.Value.ToString();
                dr3["Soluong"] = "1";
                dr3["ThanhTien"] = numExtra.Value.ToString();
                dr3["Giam"] = "0%";
                dsBill.Tables["RDatadetail"].Rows.Add(dr3);

                DataRow dr4 = dsBill.Tables["RDatadetail"].NewRow();
                dr4["STT"] = (i + 4).ToString();
                dr4["TenSanPham"] = "Thuế";
                dr4["DVT"] = ("%").ToString();
                dr4["Giam"] = "0%";
                // dr4["DonGia"] = "Phần Trăm";
                dr4["Soluong"] = numTax.Value.ToString();
                if (txtBilltotal.Text == "")
                {
                    dr4["ThanhTien"] = "0";
                }
                else
                {
                    dr4["ThanhTien"] = (Convert.ToDouble(txtBilltotal.Text) * Convert.ToDouble(numTax.Value) /
                        (100 + Convert.ToDouble(numTax.Value))).ToString("###,###,###");
                }
                dsBill.Tables["RDatadetail"].Rows.Add(dr4);
                //read Company Information form file
                //StreamReader reader = null;
                string strCompanyName = "";
                string strCompanyAddress = "";
                string strCompanyPhone = "";
                string strLoiChao1 = "";
                string strLoiChao2 = "";
                DataSet dsSetting = new DataAccess().getSettingByDate("");
                if (dsSetting != null)
                {
                    if (dsSetting.Tables[0].Rows.Count > 0)
                    {
                        if (!(dsSetting.Tables[0].Rows[0]["TenCT"] is DBNull))
                            strCompanyName = Convert.ToString(dsSetting.Tables[0].Rows[0]["TenCT"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Diachi"] is DBNull))
                            strCompanyAddress = Convert.ToString(dsSetting.Tables[0].Rows[0]["Diachi"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Phone"] is DBNull))
                            strCompanyPhone = Convert.ToString(dsSetting.Tables[0].Rows[0]["Phone"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Loichao1"] is DBNull))
                            strLoiChao1 = Convert.ToString(dsSetting.Tables[0].Rows[0]["Loichao1"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Loichao2"] is DBNull))
                            strLoiChao2 = Convert.ToString(dsSetting.Tables[0].Rows[0]["Loichao2"]);
                    }
                }

                DataRow dr = dsBill.Tables["HeaderData"].NewRow();
                dr["Ngayxuat"] =currentReceipt.Ngayxuat.ToString("dd/MM/yyyy HH:mm:ss tt");
                dr["Phong"] = "";
                dr["GiaPhong"] = "";
                dr["HoadonID"] = iCurrentReceiptID.ToString();
                dr["GioBD"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]).ToShortTimeString();
                dr["GioKT"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).ToShortTimeString();
                dr["Nhanvien"] = cboEmployee.Text;
                dr["Thue"] = numTax.Value.ToString();
                dr["Tiengiam"] = numExtra.Value.ToString();
                dr["Phuthu"] = numExtra.Value.ToString();
                dr["Tiengio"] = "";
                dr["Tienhang"] = txtProductMoney.Text;
                dr["Tongcong"] = txtBilltotal.Text;
                dr["Tratruoc"] = numDeposit.Value.ToString("###,###,##0");
                dr["Tralai"] = txtReturnMoney.Text;
                dr["TenCongTy"] = strCompanyName;
                dr["DiaChi"] = "ĐC: " + strCompanyAddress;
                dr["SoDT"] = "ĐT: " + strCompanyPhone;
                dr["Loichao1"] = strLoiChao1;
                dr["Loichao2"] = strLoiChao2;
                dsBill.Tables["HeaderData"].Rows.Add(dr);

                if (dsBill != null)
                {
                    //load last setting
                    DataSet ds = new DataAccess().getSettingByDate("");
                    string printer;
                    try
                    {
                        printer = Convert.ToString(ds.Tables[0].Rows[0]["MayInHoadon"]);
                        myPrinters.SetDefaultPrinter(printer);
                    }
                    catch
                    {
                        MessageBox.Show("Chưa cài đặt máy in!", "Thông báo");
                    }
                    frmViewReport frmView = new frmViewReport(dsBill);
                    if (frmView.ShowDialog() == DialogResult.Yes)
                    {
                        //update bill
                        //Hoadonxuat objHDXuat = new Hoadonxuat();
                        //objHDXuat.IDHoadonXuat = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDHoadonXuat"]);
                        //objHDXuat.Giam = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Giam"]);
                        //objHDXuat.GioBD = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]);
                        //objHDXuat.GioKT = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]);
                        //objHDXuat.IDPhong = iCurrentRoomID;
                        //objHDXuat.Ngayxuat = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["Ngayxuat"]).Date;
                        //objHDXuat.Phuthu = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Phuthu"]);
                        //objHDXuat.Thue = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Thue"]);
                        //objHDXuat.IDGiaLoaiphong = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDGiaLoaiphong"]);
                        //objHDXuat.IDNhanvien = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDNhanvien"]);
                        //objHDXuat.Tratruoc = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Tratruoc"]);
                        //objHDXuat.Nhacnho = Convert.ToBoolean(dsHD.Tables[0].Rows[0]["Nhacnho"]);
                        //objHDXuat.IDKhachhang = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDKhachhang"]);
                        //objHDXuat.Ghichu = Convert.ToString(dsHD.Tables[0].Rows[0]["Ghichu"]);
                        currentReceipt.Trangthai = 1;
                        if (new DataAccess().updateHoadonxuat(currentReceipt) == false)
                            MessageBox.Show("Lỗi dữ liệu", "Thông báo");
                        updateBillDisplay(iCurrentReceiptID);
                    }
                }
            }
        }
Esempio n. 4
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     frmViewReport frmView = new frmViewReport(detailVanDe);
     frmView.Show();
 }
Esempio n. 5
0
        private void printReceipt()
        {
            if (iCurrentReceiptID >= 0)
            {
                int i;
                DataSetHoaDon dsBill = new DataSetHoaDon();
                DataSet dsSP = new DataAccess().getSumChitietHDXuatByID(iCurrentReceiptID);
                DataSet dsHD = new DataAccess().getHoadonxuatByIDHoadonXuat(iCurrentReceiptID);
                int receiptStat = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Trangthai"]);
                if ((receiptStat != (int)ReceiptStatus.Open)&&(Program.userLevel != Level.Admin))
                {
                    MessageBox.Show("Hóa đơn đã được in. Liên hệ với quản lý để in lại.", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                for (i = 0; i < dsSP.Tables[0].Rows.Count; i++)
                {
                    DataRow dr1 = dsBill.Tables["RDatadetail"].NewRow();
                    dr1["STT"] = (i + 1).ToString();
                    dr1["TenSanPham"] = dsSP.Tables[0].Rows[i]["TenSanPham"].ToString();
                    dr1["DVT"] = dsSP.Tables[0].Rows[i]["DVT"].ToString();
                    dr1["DonGia"] = dsSP.Tables[0].Rows[i]["Gia"].ToString();
                    dr1["Giam"] = dsSP.Tables[0].Rows[i]["Giam"].ToString() + "%";
                    dr1["Soluong"] = dsSP.Tables[0].Rows[i]["Soluong"].ToString();
                    dr1["ThanhTien"] = Convert.ToDecimal(dsSP.Tables[0].Rows[i]["Thanhtien"]).ToString("###,###,###,###");

                    dsBill.Tables["RDatadetail"].Rows.Add(dr1);
                }
                DataRow dr2 = dsBill.Tables["RDatadetail"].NewRow();
                dr2["STT"] = (i + 2).ToString();
                dr2["TenSanPham"] = "Tiền phòng";
                dr2["DVT"] = ("Giờ").ToString();
                dr2["DonGia"] = txtRoomPrice.Text;
                TimeSpan ts = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).Subtract(Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]));
                //add extra 10 minutes to open receipt
                if((Convert.ToBoolean(dsHD.Tables[0].Rows[0]["Nhacnho"])==false) && (receiptStat == (int)ReceiptStatus.Open))
                    ts = (DateTime.Now.Subtract(Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]))).Add(new TimeSpan(0,10,0));
                //double playmin = ts.Hours + Convert.ToDouble(ts.Minutes) / 60;
                dr2["Soluong"] = ts.Hours.ToString()+"h"+ts.Minutes.ToString();
                dr2["ThanhTien"] = txtHourMoney.Text;
                dr2["Giam"] = Convert.ToString(dsHD.Tables[0].Rows[0]["Giam"]) + "%";
                dsBill.Tables["RDatadetail"].Rows.Add(dr2);

                DataRow dr3 = dsBill.Tables["RDatadetail"].NewRow();
                dr3["STT"] = (i + 3).ToString();
                dr3["TenSanPham"] = "Phụ thu";
                //dr3["DVT"] = ("").ToString();
                dr3["DonGia"] = numExtra.Value.ToString();
                dr3["Soluong"] = "1";
                dr3["ThanhTien"] = numExtra.Value.ToString();
                dr3["Giam"] = "0%";
                dsBill.Tables["RDatadetail"].Rows.Add(dr3);

                DataRow dr31 = dsBill.Tables["RDatadetail"].NewRow();
                dr31["STT"] = (i + 3).ToString();
                dr31["TenSanPham"] = "KM Đặc biệt";
                //dr3["DVT"] = ("").ToString();
                dr31["DonGia"] = numReduce.Value.ToString();
                dr31["Soluong"] = "1";
                dr31["ThanhTien"] = numReduce.Value.ToString();
                dr31["Giam"] = "0%";
                dsBill.Tables["RDatadetail"].Rows.Add(dr31);

                DataRow dr4 = dsBill.Tables["RDatadetail"].NewRow();
                dr4["STT"] = (i + 4).ToString();
                dr4["TenSanPham"] = "Thuế";
                dr4["DVT"] = ("%").ToString();
                dr4["Giam"] = "0%";
                // dr4["DonGia"] = "Phần Trăm";
                dr4["Soluong"] = numTax.Value.ToString();
                if (txtBilltotal.Text == "")
                {
                    dr4["ThanhTien"] = "0";
                }
                else
                {
                    dr4["ThanhTien"] = (Convert.ToDouble(txtBilltotal.Text) * Convert.ToDouble(numTax.Value) /
                        (100 + Convert.ToDouble(numTax.Value))).ToString("###,###,###");
                }
                dsBill.Tables["RDatadetail"].Rows.Add(dr4);
                //read Company Information form file
                //StreamReader reader = null;
                string strCompanyName = "";
                string strCompanyAddress = "";
                string strCompanyPhone = "";
                string strLoiChao1 = "";
                string strLoiChao2 = "";
                DataSet dsSetting = new DataAccess().getSettingByDate("");
                if (dsSetting != null)
                {
                    if (dsSetting.Tables[0].Rows.Count > 0)
                    {
                        if (!(dsSetting.Tables[0].Rows[0]["TenCT"] is DBNull))
                            strCompanyName = Convert.ToString(dsSetting.Tables[0].Rows[0]["TenCT"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Diachi"] is DBNull))
                            strCompanyAddress = Convert.ToString(dsSetting.Tables[0].Rows[0]["Diachi"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Phone"] is DBNull))
                            strCompanyPhone = Convert.ToString(dsSetting.Tables[0].Rows[0]["Phone"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Loichao1"] is DBNull))
                            strLoiChao1 = Convert.ToString(dsSetting.Tables[0].Rows[0]["Loichao1"]);
                        if (!(dsSetting.Tables[0].Rows[0]["Loichao2"] is DBNull))
                            strLoiChao2 = Convert.ToString(dsSetting.Tables[0].Rows[0]["Loichao2"]);
                    }
                }

                DataRow dr = dsBill.Tables["HeaderData"].NewRow();
                dr["Ngayxuat"] = dateReceipt.Value.ToString("dd/MM/yyyy HH:mm:ss tt");
                dr["Phong"] = cboRoom.Text;
                dr["GiaPhong"] = txtRoomPrice.Text;
                dr["TenHoadon"] = dsHD.Tables[0].Rows[0]["TenHoadon"].ToString();
                dr["HoadonID"] = iCurrentReceiptID.ToString();
                dr["GioBD"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]).ToShortTimeString();
                if ((Convert.ToBoolean(dsHD.Tables[0].Rows[0]["Nhacnho"]) == false) && (receiptStat == (int)ReceiptStatus.Open))
                    dr["GioKT"] = (Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).AddMinutes(10)).ToShortTimeString();
                else
                    dr["GioKT"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]);
                dr["Nhanvien"] = cboEmployee.Text;
                dr["NhanvienHD"] = Program.userFullName;
                dr["Thue"] = numTax.Value.ToString();
                dr["Tiengiam"] = numReduce.Value.ToString();
                dr["Phuthu"] = numExtra.Value.ToString();
                dr["Tiengio"] = txtHourMoney.Text;
                dr["Tienhang"] = txtProductMoney.Text;
                dr["Tongcong"] = txtBilltotal.Text;
                dr["Tratruoc"] = numDeposit.Value.ToString("###,###,##0");
                dr["Tralai"] = txtReturnMoney.Text;
                dr["TenCongTy"] = strCompanyName;
                dr["DiaChi"] = "ĐC: " + strCompanyAddress;
                dr["SoDT"] = "ĐT: " + strCompanyPhone;
                dr["Loichao1"] = strLoiChao1;
                dr["Loichao2"] = strLoiChao2;
                dsBill.Tables["HeaderData"].Rows.Add(dr);

                if (dsBill != null)
                {
                    //load last setting
                    DataSet ds = new DataAccess().getSettingByDate("");
                    string printer;
                    try
                    {
                        printer = Convert.ToString(ds.Tables[0].Rows[0]["MayInHoadon"]);
                        myPrinters.SetDefaultPrinter(printer);
                    }
                    catch
                    {
                        MessageBox.Show("Chưa cài đặt máy in!", "Thông báo");
                    }
                    frmViewReport frmView = new frmViewReport(dsBill);
                    if (frmView.ShowDialog() == DialogResult.Yes)
                    {
                        //update bill
                        //Hoadonxuat objHDXuat = new Hoadonxuat();
                        //objHDXuat.IDHoadonXuat = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDHoadonXuat"]);
                        //objHDXuat.Giam = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Giam"]);
                        //objHDXuat.GioBD = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]);
                        //objHDXuat.GioKT = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]);
                        //objHDXuat.IDPhong = iCurrentRoomID;
                        //objHDXuat.Ngayxuat = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["Ngayxuat"]).Date;
                        //objHDXuat.Phuthu = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Phuthu"]);
                        //objHDXuat.Thue = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Thue"]);
                        //objHDXuat.IDGiaLoaiphong = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDGiaLoaiphong"]);
                        //objHDXuat.IDNhanvien = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDNhanvien"]);
                        //objHDXuat.Tratruoc = Convert.ToInt32(dsHD.Tables[0].Rows[0]["Tratruoc"]);
                        //objHDXuat.Nhacnho = Convert.ToBoolean(dsHD.Tables[0].Rows[0]["Nhacnho"]);
                        //objHDXuat.IDKhachhang = Convert.ToInt32(dsHD.Tables[0].Rows[0]["IDKhachhang"]);
                        //objHDXuat.Ghichu = Convert.ToString(dsHD.Tables[0].Rows[0]["Ghichu"]);
                        //mark status of this receipt
                        if (receiptStat == (int)ReceiptStatus.Open)
                        {
                            if (Convert.ToBoolean(dsHD.Tables[0].Rows[0]["Nhacnho"]) == false)
                            {
                                currentReceipt.GioKT = DateTime.Now.AddMinutes(10);
                                //add to list to turn off CB after 10 minutes
                                DataSet dsPhong = new DataAccess().getPhongByIDPhong(iCurrentRoomID);
                               // CBReq req = new CBReq(Convert.ToInt32(dsPhong.Tables[0].Rows[0]["Congtac"]), 10);
                               // listCBtoTurnOff.Add(req);
                            }

                            currentReceipt.Trangthai = (int)ReceiptStatus.Printed;
                            if (new DataAccess().updateHoadonxuat(currentReceipt) == false)
                                MessageBox.Show("Lỗi dữ liệu", "Thông báo");
                            updateBillDisplay(iCurrentReceiptID, false);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            frmViewReport frmView = new frmViewReport(detailVanDe);

            frmView.Show();
        }
Esempio n. 7
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (TonKhoReport != null)
     {
         frmViewReport frmView = new frmViewReport(TonKhoReport);
         frmView.Show();
     }
 }
Esempio n. 8
0
 private void btnViewReport_Click(object sender, EventArgs e)
 {
     if (detailReport != null)
     {
         frmViewReport frmView = new frmViewReport(detailReport);
         frmView.Show();
     }
 }
Esempio n. 9
0
 private void btnTKHDViewReport_Click(object sender, EventArgs e)
 {
     if (TKHDReport != null)
     {
         frmViewReport frmView = new frmViewReport(TKHDReport);
         frmView.Show();
     }
     //btnTKHDViewReport.Enabled = false;
 }
Esempio n. 10
0
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            if (iCurrentReceiptID >= 0)
            {
                int i;
                DataSetHoaDon dsBill = new DataSetHoaDon();
                DataSet dsSP = new DataAccess().getChitietHDXuatByID(iCurrentReceiptID);
                DataSet dsHD = new DataAccess().getHoadonxuatByIDHoadonXuat(iCurrentReceiptID);

                for (i = 0; i < dsSP.Tables[0].Rows.Count; i++)
                {
                    DataRow dr1 = dsBill.Tables["RDatadetail"].NewRow();
                    dr1["STT"] = (i + 1).ToString();
                    dr1["TenSanPham"] = dsSP.Tables[0].Rows[i]["TenSanPham"].ToString();
                    dr1["DVT"] = dsSP.Tables[0].Rows[i]["DVT"].ToString();
                    dr1["DonGia"] = dsSP.Tables[0].Rows[i]["Gia"].ToString();
                    dr1["Soluong"] = dsSP.Tables[0].Rows[i]["Soluong"].ToString();
                    dr1["ThanhTien"] = Convert.ToDecimal(dsSP.Tables[0].Rows[i]["Thanhtien"]).ToString("###,###,###,###");

                    dsBill.Tables["RDatadetail"].Rows.Add(dr1);
                }
                DataRow dr2 = dsBill.Tables["RDatadetail"].NewRow();
                dr2["STT"] = (i + 2).ToString();
                dr2["TenSanPham"] = "Tiền phòng";
                dr2["DVT"] = ("Giờ").ToString();
                dr2["DonGia"] = txtRoomPrice.Text;
                TimeSpan ts = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).
                    TimeOfDay.Subtract(Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]).TimeOfDay);
                double playmin = ts.Hours + Convert.ToDouble(ts.Minutes) / 60;
                dr2["Soluong"] = playmin.ToString("##.00");
                dr2["ThanhTien"] = txtHourMoney.Text;
                dsBill.Tables["RDatadetail"].Rows.Add(dr2);

                DataRow dr3 = dsBill.Tables["RDatadetail"].NewRow();
                dr3["STT"] = (i + 3).ToString();
                dr3["TenSanPham"] = "Phụ thu";
                //dr3["DVT"] = ("").ToString();
                dr3["DonGia"] = txtExtra.Text;
                dr3["Soluong"] = "1";
                dr3["ThanhTien"] = txtExtra.Text;
                dsBill.Tables["RDatadetail"].Rows.Add(dr3);

                DataRow dr4 = dsBill.Tables["RDatadetail"].NewRow();
                dr4["STT"] = (i + 4).ToString();
                dr4["TenSanPham"] = "Thuế";
                dr4["DVT"] = ("%").ToString();
                // dr4["DonGia"] = "Phần Trăm";
                dr4["Soluong"] = txtTax.Text;
                if (txtBilltotal.Text == "")
                {
                    dr4["ThanhTien"] = "0";
                }
                else
                {
                    dr4["ThanhTien"] = (Convert.ToDouble(txtBilltotal.Text) * Convert.ToDouble(txtTax.Text) /
                        (100 + Convert.ToDouble(txtTax.Text))).ToString("###,###,##0");
                }
                dsBill.Tables["RDatadetail"].Rows.Add(dr4);
                //read Company Information form file
                StreamReader reader = null;
                string strCompanyName = "";
                string strCompanyAddress = "";
                string strCompanyPhone = "";
                try
                {
                    reader = new StreamReader("COMConfig.txt");
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();
                        int indexEqual = line.IndexOf('=');
                        string title = line.Substring(0, indexEqual);
                        string data = line.Substring(indexEqual + 1, line.Length - indexEqual - 1);
                        switch (title)
                        {
                            case "[COMPORT]":
                                break;
                            case "[BAUDRATE]":
                                break;
                            case "[STOPBITS]":
                                break;
                            case "[PARITY]":
                                break;
                            case "[DATABITS]":
                                break;
                            case "[CompanyName]":
                                strCompanyName = Convert.ToString(data);
                                break;
                            case "[Address]":
                                strCompanyAddress = Convert.ToString(data);
                                break;
                            case "[Phone]":
                                strCompanyPhone = Convert.ToString(data);
                                break;
                            default:
                                break;
                        }
                    }
                    reader.Close();
                }
                catch
                {
                    MessageBox.Show("Thông tin trong file COMConfig.txt chưa đúng!. \nVui lòng cập nhật lại thông tin của file này!");

                }
                DataRow dr = dsBill.Tables["HeaderData"].NewRow();
                dr["Ngayxuat"] = txtTime.Text;
                dr["Phong"] = txtRoom.Text;
                dr["GiaPhong"] = txtRoomPrice.Text;
                dr["HoadonID"] = iCurrentReceiptID.ToString();
                dr["GioBD"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioBD"]).ToShortTimeString();
                dr["GioKT"] = Convert.ToDateTime(dsHD.Tables[0].Rows[0]["GioKT"]).ToShortTimeString();
                dr["Nhanvien"] = cboEmployee.Text;
                dr["Thue"] = txtTax.Text;
                dr["Tiengiam"] = txtReduce.Text;
                dr["Phuthu"] = txtExtra.Text;
                dr["Tiengio"] = txtHourMoney.Text;
                dr["Tienhang"] = txtProductMoney.Text;
                dr["Tongcong"] = txtBilltotal.Text;
                dr["TenCongTy"] = strCompanyName;
                dr["DiaChi"] = "ĐC: " + strCompanyAddress;
                dr["SoDT"] = "ĐT: " + strCompanyPhone;
                dsBill.Tables["HeaderData"].Rows.Add(dr);

                if (dsBill != null)
                {
                    frmViewReport frmView = new frmViewReport(dsBill);
                    frmView.Show();
                }
            }
        }