Пример #1
0
        private void ItemClickEventHandler_Edit(object sender, EventArgs e)
        {
            // 25 isEditting gan bang true
            //isEditting = true;
            isAction = "Edit";

            state = MenuState.Update;

            if (gridViewRowClick == true)
            {
                Set4Object();
                //Disable
                this.Enabled = false;
                //
                // Truyen object LOC to DELEGATE
                F_CUSTOMER_Details F_CUS_Dtl = new Class.F_CUSTOMER_Details();
                F_CUS_Dtl.CUS         = this.CUS;
                F_CUS_Dtl.isAction    = this.isAction;
                F_CUS_Dtl.myFinished += this.finished;
                F_CUS_Dtl.Show();
            }
            else
            {
                XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                args.AutoCloseOptions.Delay = 3000;
                args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                args.DefaultButtonIndex = 0;
                args.Caption            = "Lưu ý ";
                args.Text    = "Vui lòng click vào dòng cần chỉnh sửa . Thông báo này sẽ tự đóng sau 3 giây.";
                args.Buttons = new DialogResult[] { DialogResult.OK };
                XtraMessageBox.Show(args).ToString();
            }
        }
Пример #2
0
        private void ItemClickEventHandler_Add(object sender, EventArgs e)
        {
            isAction = "Add";

            state = MenuState.Insert;
            //Update :  DELEGATE
            // Gọi form Details
            //Disable
            this.Enabled = false;
            //
            F_CUSTOMER_Details F_CUS_Dtl = new Class.F_CUSTOMER_Details();

            F_CUS_Dtl.isAction    = this.isAction;
            F_CUS_Dtl.CUS         = this.CUS;
            F_CUS_Dtl.myFinished += this.finished;
            F_CUS_Dtl.Show();
        }
Пример #3
0
        public F_YCXuatHD()
        {
            InitializeComponent();
            Load += (s, e) =>
            {
                this.Width  = Screen.PrimaryScreen.Bounds.Width * 3 / 5;
                this.Height = Screen.PrimaryScreen.Bounds.Height - 30;


                foreach (User _user in _userBUS.User_SELECT_Email())
                {
                    tkeTO.Properties.Tokens.Add(new TokenEditToken(_user.Email, _user.ID));
                }

                foreach (User _user in _userBUS.User_SELECT_Email())
                {
                    tkeCC.Properties.Tokens.Add(new TokenEditToken(_user.Email, _user.ID));
                }

                action_EndForm3.Add_Status(false);
                action_EndForm3.Delete_Status(false);
                action_EndForm3.Update_Status(false);
                action_EndForm3.Save_Status(true);
                action_EndForm3.View_Status(false);
                action_EndForm3.Close_Status(true);

                //btnSendMail.Enabled = false;
                //MessageBox.Show(isAction);
                dteNgayYCXuatHD.ReadOnly = true;
                dteNgayYCXuatHD.DateTime = DateTime.Now;

                if (isAction == "Edit")
                {
                    //chkGEN.ReadOnly = true;
                    //chkH2O.ReadOnly = true;
                    //chkHTH.ReadOnly = true;
                    //chkMDW.ReadOnly = true;
                    Set4Controls();
                    TDControlsReadOnly(false);
                    //XtraMessageBox.Show("Edit SoPXN :" + txtSoPXN.Text);
                    gridControl2.DataSource = this.tbl_KHMau_LABTableAdapter.FillBy(this.sYNC_NUTRICIELDataSet.tbl_KHMau_LAB, txtSoPXN.Text);
                    for (int i = 0; i < gridView2.DataRowCount; i++)
                    {
                        LstBool.Add(bool.Parse(gridView2.GetRowCellValue(i, "KetQua").ToString() == "1" ? "true" : "false"));
                    }
                }
                else if (isAction == "Add")
                {
                    xtraTabControl1.Enabled = false;
                    txtNote.ReadOnly        = true;
                    cmbKhoa.ReadOnly        = true;
                    //dteNgayCoKetQua.ReadOnly            = true;
                    //dteNgayTraKetQua.ReadOnly = true;
                    TDControlsReadOnly(true);
                    txtID.ReadOnly = true;
                }
            };

            gridView2.RowClick += (s, e) =>
            {
                gridViewRowClick2 = true;
                Set4ObjectKHMau();
                //if (gridView2.GetFocusedRowCellValue("U_InvoiceNo").ToString().Length != 0)
                //{
                //
                //}
            };

            btnXem.Click += (s, e) =>
            {
                //string filePath = string.Empty;

                //string PCname = System.Environment.MachineName;
                //if (PCname == "VPV-ASL-SAMPLE")
                //    filePath = @"D:\YCXuatHD_" + DateTime.Now.ToShortDateString().Replace("/","_") +".xlsx";
                //else
                //    filePath = @"X:\YCXuatHD_" + DateTime.Now.ToShortDateString().Replace("/", "_") + ".xlsx";
                if (cmbTuychon.SelectedText == "" || cmbTuychon.SelectedText == "Tất cả" || cmbTuychon.SelectedText == "Chưa gởi yêu cầu xuất hóa đơn")
                {
                    DataTable dTable = new DataTable();
                    dTable.Columns.Add("DocDate", typeof(string));
                    dTable.Columns.Add("SoPXN", typeof(string));
                    dTable.Columns.Add("CUSTCODE", typeof(string));
                    dTable.Columns.Add("CUSTNAME", typeof(string));
                    dTable.Columns.Add("CUSTADDRESS", typeof(string));
                    dTable.Columns.Add("TaxCode", typeof(string));
                    dTable.Columns.Add("CUSTTYPEName", typeof(string));
                    dTable.Columns.Add("MaCTXN", typeof(string));
                    dTable.Columns.Add("CTXN", typeof(string));
                    dTable.Columns.Add("DonViKHMau", typeof(string));
                    dTable.Columns.Add("SoLuongKHMau", typeof(int));
                    dTable.Columns.Add("DonGia", typeof(float));
                    dTable.Columns.Add("DonGiaSauDiscount", typeof(float));
                    dTable.Columns.Add("VAT", typeof(float));
                    dTable.Columns.Add("DonGiaSauVAT", typeof(float));
                    dTable.Columns.Add("ThanhTien", typeof(float));

                    DataTable dTableGrp = new DataTable();
                    dTableGrp.Columns.Add("Ngày xuất hóa đơn", typeof(string));
                    dTableGrp.Columns.Add("Ký hiệu mẫu", typeof(string));
                    dTableGrp.Columns.Add("Mã Đơn vị", typeof(string));
                    dTableGrp.Columns.Add("Đơn vị", typeof(string));
                    dTableGrp.Columns.Add("Địa chỉ", typeof(string));
                    //dTableGrp.Columns.Add("LOCName", typeof(string));
                    dTableGrp.Columns.Add("Mã số thuế", typeof(string));
                    dTableGrp.Columns.Add("Người gửi mẫu", typeof(string));
                    dTableGrp.Columns.Add("Khu vực", typeof(string));
                    dTableGrp.Columns.Add("Note", typeof(string));
                    dTableGrp.Columns.Add("Mã số (Code)", typeof(string));
                    dTableGrp.Columns.Add("Tên hàng hóa, dịch vụ (Description)", typeof(string));
                    dTableGrp.Columns.Add("ĐVT (Unit)", typeof(string));
                    dTableGrp.Columns.Add("Số lượng (Qty) ", typeof(int));
                    dTableGrp.Columns.Add("Giá  bán full (Chưa VAT)", typeof(float));
                    dTableGrp.Columns.Add("Discount", typeof(float));
                    dTableGrp.Columns.Add("Giá sau khi discount", typeof(float));
                    dTableGrp.Columns.Add("VAT", typeof(float));
                    dTableGrp.Columns.Add("Đơn giá sau VAT (Unit Price)", typeof(float));
                    dTableGrp.Columns.Add("Doanh thu", typeof(float));
                    dTableGrp.Columns.Add("Mua ngoài", typeof(string));
                    dTableGrp.Columns.Add("Giá mua ngoài", typeof(float));
                    foreach (int i in gridView2.GetSelectedRows())
                    {
                        //XtraMessageBox.Show(gridView2.GetRowCellValue(i, "GoiYCXuatHD").ToString());
                        if (bool.Parse(gridView2.GetRowCellValue(i, "GoiYCXuatHD").ToString()) != true)
                        {
                            dTable.Rows.Add(string.Empty,
                                            gridView2.GetRowCellValue(i, "SoPXN").ToString(),
                                            gridView2.GetRowCellValue(i, "CUSTCODE").ToString(),
                                            gridView2.GetRowCellValue(i, "CUSTNAME").ToString(),
                                            gridView2.GetRowCellValue(i, "CUSTADDRESS").ToString(),
                                            gridView2.GetRowCellValue(i, "TaxCode").ToString(),
                                            gridView2.GetRowCellValue(i, "CUSTTYPEName").ToString(),
                                            gridView2.GetRowCellValue(i, "MaCTXN").ToString(),
                                            gridView2.GetRowCellValue(i, "CTXN").ToString(),
                                            gridView2.GetRowCellValue(i, "DonViKHMau").ToString(),
                                            int.Parse(gridView2.GetRowCellValue(i, "SoLuongKHMau").ToString()),
                                            float.Parse(gridView2.GetRowCellValue(i, "DonGia").ToString()),
                                            float.Parse(gridView2.GetRowCellValue(i, "DonGiaSauDiscount").ToString()),
                                            float.Parse(gridView2.GetRowCellValue(i, "VAT").ToString()),
                                            float.Parse(gridView2.GetRowCellValue(i, "DonGia").ToString()) * (1 + float.Parse(gridView2.GetRowCellValue(i, "VAT").ToString()) / 100),
                                            float.Parse(gridView2.GetRowCellValue(i, "ThanhTien").ToString())
                                            );
                        }
                    }
                    var query = from t in dTable.AsEnumerable()
                                group t by new
                    {
                        DocDate     = string.Empty,
                        SoPXN       = t.Field <string>("SoPXN"),
                        CUSTCODE    = t.Field <string>("CUSTCODE"),
                        CUSTNAME    = t.Field <string>("CUSTNAME"),
                        CUSTADDRESS = t.Field <string>("CUSTADDRESS"),
                        //LOCName = t.Field<string>("LOCName"),
                        TaxCode      = t.Field <string>("TaxCode"),
                        CUSTTYPEName = t.Field <string>("CUSTTYPEName"),
                        CTXN         = t.Field <string>("CTXN"),
                        MaCTXN       = t.Field <string>("MaCTXN"),
                        DonViKHMau   = t.Field <string>("DonViKHMau"),
                        //sumSL
                        DonGia            = t.Field <float>("DonGia"),
                        DonGiaSauDiscount = t.Field <float>("DonGiaSauDiscount"),
                        VAT          = t.Field <float>("VAT"),
                        DonGiaSauVAT = t.Field <float>("DonGiaSauVAT"),
                        //ThanhTien = t.Field<string>("ThanhTien")
                        //sum
                    } into grp
                        select new
                    {
                        grp.Key.DocDate,
                        //.Key.SoPXN,
                        //Distinc để bỏ trùng
                        SoPXN = string.Join(";", grp.Select(r => r.Field <string>("SoPXN")).Distinct()),
                        grp.Key.CUSTCODE,
                        grp.Key.CUSTNAME,
                        grp.Key.CUSTADDRESS,
                        //grp.Key.LOCName,
                        grp.Key.TaxCode,
                        grp.Key.CUSTTYPEName,
                        grp.Key.CTXN,
                        grp.Key.MaCTXN,
                        grp.Key.DonViKHMau,
                        grp.Key.DonGia,
                        grp.Key.DonGiaSauDiscount,
                        grp.Key.VAT,
                        grp.Key.DonGiaSauVAT,
                        sumSL = grp.Sum(r => r.Field <int>("SoLuongKHMau")),
                        sum   = grp.Sum(r => r.Field <float>("ThanhTien"))
                    };

                    //gridControl1.DataSource = dTable;

                    foreach (var grp in query)
                    {
                        dTableGrp.Rows.Add(grp.DocDate,
                                           grp.SoPXN,
                                           grp.CUSTCODE,
                                           grp.CUSTNAME,
                                           grp.CUSTADDRESS,
                                           //grp.LOCName,
                                           grp.TaxCode,
                                           string.Empty,
                                           string.Empty,
                                           grp.CUSTTYPEName,
                                           grp.CTXN,
                                           grp.MaCTXN,
                                           grp.DonViKHMau,
                                           //grp.SoLuongKHMau = grp.sumSL
                                           grp.sumSL,
                                           grp.DonGia,
                                           0.00,
                                           grp.DonGiaSauDiscount,
                                           grp.VAT,
                                           grp.DonGiaSauVAT,
                                           //grp.ThanhTien = grp.sum
                                           grp.sum,
                                           string.Empty,
                                           0.00);
                        //Response.Write(String.Format("The Sum of '{0}' is {1}", grp.Id, grp.sum));
                    }
                    gridControl1.DataSource = dTableGrp;
                }
                else
                {
                    XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                    args.AutoCloseOptions.Delay = 2000;
                    args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                    args.DefaultButtonIndex = 0;
                    args.Caption            = "Không thực hiện được ";
                    args.Text    = "Dữ liệu bên trên đã xuất hóa đơn trước đây";
                    args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                    XtraMessageBox.Show(args).ToString();
                }
            };

            btnSendMail.Click += (s, e) =>
            {
                List <string> _TOList = new List <string>();
                List <string> _CCList = new List <string>();



                //foreach (string _email in _TOList)
                //XtraMessageBox.Show(_email);


                if (this.dxValidationProvider2.Validate() == true)
                {
                    //    //Kiểm tra xem user có check gửi mail không
                    foreach (TokenEditToken _tokenEditTokenTO in tkeTO.GetTokenList())
                    {
                        _TOList.Add(_tokenEditTokenTO.Description.ToString());
                    }

                    foreach (TokenEditToken _tokenEditTokenCC in tkeCC.GetTokenList())
                    {
                        _CCList.Add(_tokenEditTokenCC.Description.ToString());
                    }


                    //    _TOList = txtEmailTO.Text.Split(';');

                    //    _CCList = txtEmailCC.Text.Split(';');

                    DialogResult dlDel = XtraMessageBox.Show(" Bạn muốn gởi mail ? . Lưu ý hệ thống sẽ tiến hành gởi mail và không thể recall mail lại sau khi gởi", "Gởi mail", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dlDel == DialogResult.Yes)
                    {
                        SendMail(_TOList, _CCList, "Yêu cầu xuất hóa đơn", path);
                        XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                        args.AutoCloseOptions.Delay = 2000;
                        args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                        args.DefaultButtonIndex = 0;
                        args.Caption            = "Đã gởi mail ";
                        args.Text    = "Nội dung yêu cầu xuất hóa đơn đã gởi cho bộ phận CS.";
                        args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                        XtraMessageBox.Show(args).ToString();
                    }
                    else
                    {
                        XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                        args.AutoCloseOptions.Delay = 2000;
                        args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                        args.DefaultButtonIndex = 0;
                        args.Caption            = "Hủy mail ";
                        args.Text    = "Mail gởi đã hủy.";
                        args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                        XtraMessageBox.Show(args).ToString();
                    }
                }
                else
                {
                    XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                    args.AutoCloseOptions.Delay = 2000;
                    args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                    args.DefaultButtonIndex = 0;
                    args.Caption            = "Không có mail người nhận ";
                    args.Text    = "Mail gởi đã hủy.";
                    args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                    XtraMessageBox.Show(args).ToString();
                }
            };
            //Tra ket qua cho kach hang
            //Chi khi tat ca cac dong co gia tri cua TraKetQua = true thi moi xu ly
            btnTraKetQua.Click += (s, e) =>
            {
                //if (gridView2.GetFocusedRowCellValue("GoiYCXuatHD").ToString() == "False")
                //{
                DialogResult dlDel = XtraMessageBox.Show(" Bạn muốn xuất hóa đơn cho dữ liệu đã chọn bên trên ? . " +
                                                         "Lưu ý hệ thống sẽ ghi nhận hôm nay là ngày yêu cầu xuất hóa đơn", "Xuất hóa đơn", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dlDel == DialogResult.Yes)
                {
                    //foreach (int i in gridView2.GetSelectedRows())
                    //{
                    //        KHMauCTXNBUS.KHMau_CTXN_LABBUS_UPDATE_GoiYCXuatHD(gridView2.GetRowCellValue(i, "KHMau").ToString(), int.Parse(gridView2.GetRowCellValue(i, "CTXNID").ToString()));
                    //}
                    txtSubject.Text = "VIPHALAB : Yêu cầu xuất hóa đơn ngày " + DateTime.Now.ToShortDateString().Replace("/", "_") + " cho khách hàng code " + OBJ.MaCoSoLayMau;

                    //Export
                    gridView1.ExportToXlsx(path);
                    System.Diagnostics.Process.Start(path);
                }
                //}
            };

            gridView2.RowClick += (s, e) =>
            {
                gridViewRowClick = true;
                Set4ObjectKHMau();
            };

            gridView2.InitNewRow += (s, e) =>
            {
                gridViewRowClick = true;
            };

            //this.FormClosed += (s, e) =>
            //{
            //};

            txtNote.TextChanged += (s, e) =>
            {
                if (isAction == "Edit" || isChanged == "Changed")
                {
                    //btnSave.Enabled = true;
                    isChanged = "Changed";
                }
            };

            cmbKhoa.TextChanged += (s, e) =>
            {
                if (isAction == "Edit" || isChanged == "Changed")
                {
                    // btnSave.Enabled = true;
                    isChanged = "Changed";
                }
            };

            dteNgayYCXuatHD.EditValueChanged += (s, e) =>
            {
                //dteNgayDukienTra.ReadOnly = false;
            };

            lkeTenCoSoLayMau.ButtonClick += (s, e) =>
            {
                if (e.Button.Index == 1)
                {
                    //Disable
                    this.Enabled = false;
                    //
                    F_CUSTOMER_Details F_CUS_Dtl = new Class.F_CUSTOMER_Details();
                    F_CUS_Dtl.isAction = this.isAction;
                    //F_CUS_Dtl.CUS = this.CUS;
                    F_CUS_Dtl.myFinished += this.finished;
                    F_CUS_Dtl.Show();
                }
            };

            cmbTuychon.SelectedValueChanged += (s, e) =>
            {
                if (OBJ.MaCoSoLayMau.Length > 0)
                {
                    if (cmbTuychon.SelectedText == "Đã gởi yêu cầu xuất hóa đơn")
                    {
                        //XtraMessageBox.Show(OBJ.DonViXuatHoaDon_ID.ToString());
                        gridControl2.DataSource = tbl_KHMau_LABTableAdapter.FillBy_DonViXuatHoaDon_ID_DagoiYCXHD(sYNC_NUTRICIELDataSet.tbl_KHMau_LAB, OBJ.DonViXuatHoaDon_ID);
                    }
                    else if (cmbTuychon.SelectedText == "Chưa gởi yêu cầu xuất hóa đơn")
                    {
                        gridControl2.DataSource = tbl_KHMau_LABTableAdapter.FillBy_DonViXuatHoaDon_ID_ChuagoiYCXHD(sYNC_NUTRICIELDataSet.tbl_KHMau_LAB, OBJ.DonViXuatHoaDon_ID);
                    }
                    else
                    {
                        gridControl2.DataSource = tbl_KHMau_LABTableAdapter.FillBy_DonViXuatHoaDon_ID(sYNC_NUTRICIELDataSet.tbl_KHMau_LAB, OBJ.DonViXuatHoaDon_ID);
                    }

                    gridView2.BestFitColumns();
                }
                else
                {
                    XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                    args.AutoCloseOptions.Delay = 2000;
                    args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                    args.DefaultButtonIndex = 0;
                    args.Caption            = "Lưu ý ";
                    args.Text    = "Không tìm thấy chỉ tiêu . Thông báo này sẽ tự đóng sau 2 giây.";
                    args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                    XtraMessageBox.Show(args).ToString();
                }
            };

            lkeTenCoSoLayMau.EditValueChanged += (s, e) =>
            {
                DataRowView rowView = (DataRowView)lkeTenCoSoLayMau.GetSelectedDataRow();
                DataRow     row     = rowView.Row;
                txtDCCoSoLayMau.Text    = row["CUSTADDRESS"].ToString();
                txtEmailCoSoLayMau.Text = row["ContactEmail"].ToString();
                txtPhoneCoSoLayMau.Text = row["CUSTPHONE"].ToString();
                //////////////////////////////////////////////////////////////////////////////////////////
                OBJ.MaCoSoLayMau       = row["CUSTCODE"].ToString();
                OBJ.CUSTCODE_ID        = int.Parse(row["Id"].ToString());
                OBJ.DonViXuatHoaDon_ID = int.Parse(row["Id"].ToString());

                if (PCname == "vpv-lab-sample")
                {
                    path = @"D:\YC_xuat_HD_" + DateTime.Now.ToShortDateString().Replace("/", "_") + "_" + OBJ.MaCoSoLayMau + ".xlsx";
                }
                else
                {
                    path = @"X:\YC_xuat_HD_" + DateTime.Now.ToShortDateString().Replace("/", "_") + "_" + OBJ.MaCoSoLayMau + ".xlsx";
                }
            };

            action_EndForm3.Close(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Close3));
            action_EndForm3.Save(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Save3));
        }