Exemple #1
0
        private void bbiInPhieu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            object machungtucamdo = gbList.GetFocusedRowCellValue(colMa_Chung_Tu);
            if (machungtucamdo == null)
                return;

            bool inthongtinrutgon = false;
            if (XtraMessageBox.Show("Bạn có muốn hiển thị thông tin rút gọn trong phiếu in hay không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                inthongtinrutgon = true;
            }

            var rpt = new rptPhieuInCamDo(machungtucamdo.ToString(), inthongtinrutgon);
            //rpt.ShowPreview();

            rpt.AssignPrintTool(new ReportPrintTool(rpt));
            rpt.CreateDocument();
            rpt.ShowPreview();
        }
Exemple #2
0
        private void bbiLuu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gbList.FocusedRowHandle += 1;
            gbList.UpdateCurrentRow();

            if (!Kiem_Tra())
            {
                return;
            }

            DB_Quan_Ly_Cam_DoDataContext database = new DB_Quan_Ly_Cam_DoDataContext(SqlHelper.ConnectionString);
            try
            {
                database.Connection.Open();
                System.Data.Common.DbTransaction transaction = database.Connection.BeginTransaction();
                database.Transaction = transaction;

                if (tinh_trang == "them")
                {
                    CHUNG_TU chung_tu = new CHUNG_TU
                    {
                        Ma_Chung_Tu = txtMaChungTu.Text,
                        So = txtSo.Text,
                        Lien = txtLien.Text,
                        Ngay = txtNgay.DateTime,
                        Ten_Khach_Hang = txtKhachHang.Text,
                        So_CMND = txtCMNDSo.Text,
                        Ngay_Cap_CMND = txtNgayCap.Text,
                        Noi_Cap = txtNoiCap.Text,
                        Ngay_Sinh = txtNgaySinh.Text,
                        Dia_Chi = txtDiaChi.Text,
                        So_Dien_Thoai = txtSoDienThoai.Text,
                        Chu_Tiem = txtChuTiem.Text,
                        So_Tien_Cam = txtSoTienCam.Value,
                        Tu_Ngay = txtTuNgay.Text,
                        Den_Ngay = txtDenNgay.Text,
                        Lai_Suat_Ngay = txtLaiSuatNgay.Value,
                        Lai_Suat_Thang = txtLaiSuatThang.Value,
                        Da_Chuoc = false,
                        Ghi_Chu = txtGhiChu.Text,
                        //Tien_Lai_Cu = txtTienLaiCu.Value,
                        //Chung_Tu_Goc = txtChungTuGoc.Text,
                        Da_Lam_Lai_Giay = false,
                        Mat_Giay = false,
                        Sap_Xep = 0
                    };
                    database.CHUNG_TUs.InsertOnSubmit(chung_tu);

                }
                else
                {
                    var chung_tu = (from ct in database.CHUNG_TUs
                                    where ct.Ma_Chung_Tu == txtMaChungTu.Text
                                    select ct).FirstOrDefault();

                    chung_tu.Ma_Chung_Tu = txtMaChungTu.Text;
                    chung_tu.So = txtSo.Text;
                    chung_tu.Lien = txtLien.Text;
                    chung_tu.Ngay = txtNgay.DateTime;
                    chung_tu.Ten_Khach_Hang = txtKhachHang.Text;
                    chung_tu.So_CMND = txtCMNDSo.Text;
                    chung_tu.Ngay_Cap_CMND = txtNgayCap.Text;
                    chung_tu.Noi_Cap = txtNoiCap.Text;
                    chung_tu.Ngay_Sinh = txtNgaySinh.Text;
                    chung_tu.Dia_Chi = txtDiaChi.Text;
                    chung_tu.So_Dien_Thoai = txtSoDienThoai.Text;
                    chung_tu.Chu_Tiem = txtChuTiem.Text;
                    chung_tu.So_Tien_Cam = txtSoTienCam.Value;
                    chung_tu.Tu_Ngay = txtTuNgay.Text;
                    chung_tu.Den_Ngay = txtDenNgay.Text;
                    chung_tu.Lai_Suat_Ngay = txtLaiSuatNgay.Value;
                    chung_tu.Lai_Suat_Thang = txtLaiSuatThang.Value;
                    chung_tu.Da_Chuoc = false;
                    chung_tu.Ghi_Chu = txtGhiChu.Text;
                    //chung_tu.Tien_Lai_Cu = txtTienLaiCu.Value;
                    //chung_tu.Chung_Tu_Goc = txtChungTuGoc.Text;
                    chung_tu.Da_Lam_Lai_Giay = false;
                    chung_tu.Mat_Giay = false;
                    chung_tu.Sap_Xep = 0;
                }

                string ket_qua = "";

                //if (lcChungTuGoc.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always && !string.IsNullOrEmpty(txtChungTuGoc.Text))
                //{
                //    ket_qua = Luu_Lam_Giay_Moi(database);
                //    if (ket_qua != "OK")
                //    {
                //        database.Transaction.Rollback();
                //        MessageBox.Show(ket_qua);
                //    }
                //}

                ket_qua = Luu_Chi_Tiet(database);
                if (ket_qua == "OK")
                {
                    database.SubmitChanges();
                    database.Transaction.Commit();
                    database.Connection.Close();

                    if (InPhieu)
                    {
                        var rpt = new rptPhieuInCamDo(txtMaChungTu.Text, cbInThongTinRutGon.Checked);
                        //rpt.AssignPrintTool(new ReportPrintTool(rpt));
                        rpt.CreateDocument();
                        //rpt.ShowPreview();

                        int lien = 0;
                        if (int.TryParse(txtLien.Text, out lien))
                        {
                            for (int i = 0; i < lien - 1; i++)
                            {
                                var rpt_add = new rptPhieuInCamDo(txtMaChungTu.Text, false);
                                rpt_add.CreateDocument();

                                rpt.Pages.AddRange(rpt_add.Pages);
                            }
                        }

                        rpt.PrintingSystem.ContinuousPageNumbering = true;
                        ReportPrintTool printTool = new ReportPrintTool(rpt);
                        printTool.ShowPreview();
                    }

                    InPhieu = false;
                    RaiseReloadEventHander();
                    Close();

                }
                else
                {
                    database.Transaction.Rollback();
                    MessageBox.Show(ket_qua);
                }

            }
            catch (Exception ex)
            {
                database.Transaction.Rollback();
                MessageBox.Show(ex.ToString());
            }
        }