Ejemplo n.º 1
0
        public static Result UpdateGiaDichVuXetNghiem(string key, double soTien)
        {
            Result     result = new Result();
            MMOverride db     = null;

            try
            {
                db = new MMOverride();
                using (TransactionScope t = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 30, 0)))
                {
                    string            desc = string.Empty;
                    ThucHienXetNghiem thxn = db.ThucHienXetNghiems.SingleOrDefault <ThucHienXetNghiem>(x => x.ThucHienXetNghiemGUID.ToString() == key);
                    if (thxn != null)
                    {
                        thxn.SoTien      = soTien;
                        thxn.UpdatedDate = DateTime.Now;
                        thxn.UpdatedBy   = Guid.Parse(Global.UserGUID);

                        desc = string.Format("- GUID: '{0}', Ngày thực hiện: '{1}', Tên công ty: '{2}', Tên khách hàng: '{3}', Tên dịch vụ: '{4}', Số tiền: '{5}', Source: '{6}'",
                                             thxn.ThucHienXetNghiemGUID.ToString(), thxn.NgayThucHien.ToString("dd/MM/yyyy"), thxn.TenCongTy, thxn.TenKhachHang, thxn.TenDichVu, soTien, thxn.SourcePath);

                        //Tracking
                        Tracking tk = new Tracking();
                        tk.TrackingGUID = Guid.NewGuid();
                        tk.TrackingDate = DateTime.Now;
                        tk.DocStaffGUID = Guid.Parse(Global.UserGUID);
                        tk.ActionType   = (byte)ActionType.Delete;
                        tk.Action       = "Sửa giá dịch vụ xét nghiệm";
                        tk.Description  = desc;
                        tk.TrackingType = (byte)TrackingType.Price;
                        tk.ComputerName = Utility.GetDNSHostName();
                        db.Trackings.InsertOnSubmit(tk);
                    }

                    db.SubmitChanges();
                    t.Complete();
                }
            }
            catch (System.Data.SqlClient.SqlException se)
            {
                result.Error.Code        = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT;
                result.Error.Description = se.ToString();
            }
            catch (Exception e)
            {
                result.Error.Code        = ErrorCode.UNKNOWN_ERROR;
                result.Error.Description = e.ToString();
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                    db = null;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static Result InsertDichVuXetNghiem(ThucHienXetNghiem xn)
        {
            Result     result = new Result();
            MMOverride db     = null;

            try
            {
                db = new MMOverride();
                using (TransactionScope t = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 30, 0)))
                {
                    string desc = string.Empty;
                    //ThucHienXetNghiem thxn = db.ThucHienXetNghiems.FirstOrDefault<ThucHienXetNghiem>(x => x.NgayThucHien == xn.NgayThucHien &&
                    //    x.TenCongTy.Trim().ToUpper() == xn.TenCongTy.Trim().ToUpper() &&
                    //    x.TenKhachHang.Trim().ToUpper() == xn.TenKhachHang.Trim().ToUpper() &&
                    //    x.TenDichVu.Trim().ToUpper() == xn.TenDichVu.Trim().ToUpper());

                    //ThucHienXetNghiem thxn = db.ThucHienXetNghiems.FirstOrDefault<ThucHienXetNghiem>(x => x.SourcePath.Trim().ToLower() == xn.SourcePath.Trim().ToLower());

                    //if (thxn == null)
                    {
                        xn.ThucHienXetNghiemGUID = Guid.NewGuid();
                        xn.CreatedDate           = DateTime.Now;
                        xn.CreatedBy             = Guid.Parse(Global.UserGUID);
                        xn.Status = (byte)Status.Actived;
                        db.ThucHienXetNghiems.InsertOnSubmit(xn);

                        desc = string.Format("- GUID: '{0}', Ngày thực hiện: '{1}', Tên công ty: '{2}', Tên khách hàng: '{3}', Tên dịch vụ: '{4}', Số tiền: '{5}', Source: '{6}'",
                                             xn.ThucHienXetNghiemGUID.ToString(), xn.NgayThucHien.ToString("dd/MM/yyyy"), xn.TenCongTy, xn.TenKhachHang, xn.TenDichVu, xn.SoTien, xn.SourcePath);

                        //Tracking
                        desc = desc.Substring(0, desc.Length - 1);
                        Tracking tk = new Tracking();
                        tk.TrackingGUID = Guid.NewGuid();
                        tk.TrackingDate = DateTime.Now;
                        tk.DocStaffGUID = Guid.Parse(Global.UserGUID);
                        tk.ActionType   = (byte)ActionType.Delete;
                        tk.Action       = "Thêm dịch vụ xét nghiệm";
                        tk.Description  = desc;
                        tk.TrackingType = (byte)TrackingType.Price;
                        tk.ComputerName = Utility.GetDNSHostName();
                        db.Trackings.InsertOnSubmit(tk);
                    }
                    //else
                    //{
                    //    thxn.SoTien = xn.SoTien;
                    //    thxn.SourcePath = xn.SourcePath;
                    //    thxn.UpdatedBy = Guid.Parse(Global.UserGUID);
                    //    thxn.UpdatedDate = DateTime.Now;
                    //    thxn.Status = (byte)Status.Actived;

                    //    desc = string.Format("- GUID: '{0}', Ngày thực hiện: '{1}', Tên công ty: '{2}', Tên khách hàng: '{3}', Tên dịch vụ: '{4}', Số tiền: '{5}', Source: '{6}'",
                    //        thxn.ThucHienXetNghiemGUID.ToString(), thxn.NgayThucHien.ToString("dd/MM/yyyy"), thxn.TenCongTy, thxn.TenKhachHang, thxn.TenDichVu, thxn.SoTien, thxn.SourcePath);

                    //    Tracking
                    //    desc = desc.Substring(0, desc.Length - 1);
                    //    Tracking tk = new Tracking();
                    //    tk.TrackingGUID = Guid.NewGuid();
                    //    tk.TrackingDate = DateTime.Now;
                    //    tk.DocStaffGUID = Guid.Parse(Global.UserGUID);
                    //    tk.ActionType = (byte)ActionType.Delete;
                    //    tk.Action = "Sửa dịch vụ xét nghiệm";
                    //    tk.Description = desc;
                    //    tk.TrackingType = (byte)TrackingType.Price;
                    //    db.Trackings.InsertOnSubmit(tk);
                    //}

                    db.SubmitChanges();
                    t.Complete();
                }
            }
            catch (System.Data.SqlClient.SqlException se)
            {
                result.Error.Code        = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT;
                result.Error.Description = se.ToString();
            }
            catch (Exception e)
            {
                result.Error.Code        = ErrorCode.UNKNOWN_ERROR;
                result.Error.Description = e.ToString();
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                    db = null;
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        private void OnImportExcel(string fileName)
        {
            int row = 7;

            try
            {
                IWorkbook book = SpreadsheetGear.Factory.GetWorkbook(fileName);
                if (book.Worksheets.Count <= 0)
                {
                    return;
                }

                IWorksheet workSheet = book.Worksheets[0];
                string     msg       = "Nhập dữ liệu từ Excel hoàn tất." + System.Environment.NewLine;
                if (!CheckTemplate(workSheet, ref msg))
                {
                    MsgBox.Show(Application.ProductName, msg, IconType.Information);
                    return;
                }

                while (true)
                {
                    IRange range = workSheet.Cells[string.Format("B{0}", row)];
                    if (range.Value == null || range.Value.ToString().Trim() == string.Empty ||
                        range.Value.ToString().Trim().ToLower() == "tổng")
                    {
                        break;
                    }

                    DateTime          ngayThucHien = Convert.ToDateTime(workSheet.Cells[string.Format("D{0}", row)].Text);
                    string            tenCongTy    = workSheet.Cells[string.Format("E{0}", row)].Value.ToString().Trim();
                    string            tenKhachHang = workSheet.Cells[string.Format("F{0}", row)].Value.ToString().Trim();
                    string            tenDichVu    = workSheet.Cells[string.Format("I{0}", row)].Value.ToString().Trim();
                    double            soTien       = Convert.ToDouble(workSheet.Cells[string.Format("J{0}", row)].Value);
                    ThucHienXetNghiem thxn         = new ThucHienXetNghiem();
                    thxn.NgayThucHien = ngayThucHien;
                    thxn.TenCongTy    = tenCongTy;
                    thxn.TenKhachHang = tenKhachHang;
                    thxn.TenDichVu    = tenDichVu;
                    thxn.SoTien       = soTien;
                    thxn.SourcePath   = fileName;
                    Result result = ThucHienXetNghiemBus.InsertDichVuXetNghiem(thxn);
                    if (!result.IsOK)
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThucHienXetNghiemBus.InsertDichVuXetNghiem"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ThucHienXetNghiemBus.InsertDichVuXetNghiem"));
                        return;
                    }

                    row++;
                }

                MsgBox.Show(Application.ProductName, msg, IconType.Information);
                InitData();
                DisplayAsThread();
            }
            catch (Exception ex)
            {
                MsgBox.Show(Application.ProductName, ex.Message, IconType.Error);
                Utility.WriteToTraceLog(ex.Message);
            }
        }