Esempio n. 1
0
        private void OnDisplayServiceList(string serviceGroupGUID)
        {
            Result result = ServiceGroupBus.GetServiceListByGroup(serviceGroupGUID);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    dgService.DataSource = result.QueryResult;
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ServiceGroupBus.GetServiceListByGroup"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceGroupBus.GetServiceListByGroup"));
            }
        }
Esempio n. 2
0
        private void OnDisplayServiceGroupList()
        {
            Result result = ServiceGroupBus.GetServicesGroupList();

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearData();
                    dgServiceGroup.DataSource = result.QueryResult;
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServiceGroupBus.GetServicesGroupList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceGroupBus.GetServicesGroupList"));
            }
        }
Esempio n. 3
0
        private void GenerateCode()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = ServiceGroupBus.GetServiceGroupCount();

            if (result.IsOK)
            {
                int count = Convert.ToInt32(result.QueryResult);
                txtCode.Text = Utility.GetCode("NDV", count + 1, 4);
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ServiceGroupBus.GetServiceGroupCount"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ServiceGroupBus.GetServiceGroupCount"));
            }
        }
Esempio n. 4
0
        private void OnSaveInfo()
        {
            try
            {
                _serviceGroup.Code        = txtCode.Text;
                _serviceGroup.Name        = txtName.Text;
                _serviceGroup.EnglishName = string.Empty;
                _serviceGroup.Note        = txtNote.Text;
                _serviceGroup.Status      = (byte)Status.Actived;

                if (_isNew)
                {
                    _serviceGroup.CreatedDate = DateTime.Now;
                    _serviceGroup.CreatedBy   = Guid.Parse(Global.UserGUID);
                }
                else
                {
                    _serviceGroup.UpdatedDate = DateTime.Now;
                    _serviceGroup.UpdatedBy   = Guid.Parse(Global.UserGUID);
                }

                List <Service_ServiceGroup> addedList = new List <Service_ServiceGroup>();
                foreach (string serviceGUID in _addedServices)
                {
                    Service_ServiceGroup ssg = new Service_ServiceGroup();
                    ssg.ServiceGUID = Guid.Parse(serviceGUID);
                    ssg.CreatedDate = DateTime.Now;
                    ssg.DeletedBy   = Guid.Parse(Global.UserGUID);
                    ssg.Status      = (byte)Status.Actived;
                    addedList.Add(ssg);
                }

                Result result = ServiceGroupBus.InsertServiceGroup(_serviceGroup, addedList, _deletedServices);
                if (!result.IsOK)
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("ServiceGroupBus.InsertServiceGroup"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("ServiceGroupBus.InsertServiceGroup"));
                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                }
            }
            catch (Exception e)
            {
                MsgBox.Show(this.Text, e.Message, IconType.Error);
                Utility.WriteToTraceLog(e.Message);
            }
        }
Esempio n. 5
0
        private void OnDeleteServiceGroup()
        {
            List <string>  deletedServiceGroupList = new List <string>();
            List <DataRow> deletedRows             = new List <DataRow>();
            DataTable      dt = dgServiceGroup.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    deletedServiceGroupList.Add(row["ServiceGroupGUID"].ToString());
                    deletedRows.Add(row);
                }
            }

            if (deletedServiceGroupList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những nhóm dịch vụ mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = ServiceGroupBus.DeleteServiceGroup(deletedServiceGroupList);
                    if (result.IsOK)
                    {
                        foreach (DataRow row in deletedRows)
                        {
                            dt.Rows.Remove(row);
                        }
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServiceGroupBus.DeleteServiceGroup"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ServiceGroupBus.DeleteServiceGroup"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những nhóm dịch vụ cần xóa.", IconType.Information);
            }
        }
Esempio n. 6
0
        public static void PrintChecklist(object reportFileName, DataRow patientRow, DataRow[] serviceRows, string printerName, bool isPrint)
        {
            string fileNum  = patientRow["FileNum"].ToString();
            string fullName = patientRow["FullName"].ToString();
            string dob      = patientRow["DobStr"].ToString();
            string gender   = patientRow["GenderAsStr"].ToString();
            string address  = patientRow["Address"] as string;
            string mobile   = patientRow["Mobile"] as string;
            string email    = patientRow["Email"] as string;

            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document    doc  = new Microsoft.Office.Interop.Word.Document();
            object missing = System.Type.Missing;

            try
            {
                doc = word.Documents.Open(ref reportFileName,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing);

                doc.Activate();

                foreach (Microsoft.Office.Interop.Word.Range tmpRange in doc.StoryRanges)
                {
                    tmpRange.Find.Text             = "#N";
                    tmpRange.Find.Replacement.Text = fullName;
                    tmpRange.Find.Wrap             = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
                    object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
                    tmpRange.Find.Execute(ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref replaceAll,
                                          ref missing, ref missing, ref missing, ref missing);

                    tmpRange.Find.Text             = "#S";
                    tmpRange.Find.Replacement.Text = gender;
                    tmpRange.Find.Wrap             = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
                    replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
                    tmpRange.Find.Execute(ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref replaceAll,
                                          ref missing, ref missing, ref missing, ref missing);

                    tmpRange.Find.Text             = "#D";
                    tmpRange.Find.Replacement.Text = dob;
                    tmpRange.Find.Wrap             = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
                    replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
                    tmpRange.Find.Execute(ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref replaceAll,
                                          ref missing, ref missing, ref missing, ref missing);

                    tmpRange.Find.Text             = "#A";
                    tmpRange.Find.Replacement.Text = address;
                    tmpRange.Find.Wrap             = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
                    replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
                    tmpRange.Find.Execute(ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref replaceAll,
                                          ref missing, ref missing, ref missing, ref missing);

                    tmpRange.Find.Text             = "#T";
                    tmpRange.Find.Replacement.Text = mobile;
                    tmpRange.Find.Wrap             = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
                    replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
                    tmpRange.Find.Execute(ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref replaceAll,
                                          ref missing, ref missing, ref missing, ref missing);

                    tmpRange.Find.Text             = "#E";
                    tmpRange.Find.Replacement.Text = email;
                    tmpRange.Find.Wrap             = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
                    replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
                    tmpRange.Find.Execute(ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref missing,
                                          ref missing, ref missing, ref missing, ref replaceAll,
                                          ref missing, ref missing, ref missing, ref missing);
                }

                if (doc.Sections != null && doc.Sections.Count > 0)
                {
                    doc.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = string.Format("CODE: {0}", fileNum);
                }

                //Fill Services
                int no = 2;
                Microsoft.Office.Interop.Word.Row dr = null;
                if (serviceRows != null && serviceRows.Length > 0)
                {
                    List <string> servicesNameList = new List <string>();
                    Hashtable     htServiceGroup   = new Hashtable();
                    foreach (DataRow row in serviceRows)
                    {
                        string serviceGUID = row["ServiceGUID"].ToString();
                        string serviceName = row["Name"].ToString();

                        Result result = ServiceGroupBus.GetServiceGroup(serviceGUID);
                        if (!result.IsOK)
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServiceGroupBus.GetServiceGroup"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("ServiceGroupBus.GetServiceGroup"));
                            return;
                        }
                        else
                        {
                            if (result.QueryResult == null)
                            {
                                servicesNameList.Add(serviceName);
                            }
                            else
                            {
                                ServiceGroup serviceGroup = result.QueryResult as ServiceGroup;
                                string       groupName    = serviceGroup.Name;
                                if (htServiceGroup.ContainsKey(groupName))
                                {
                                    List <string> serviceList = (List <string>)htServiceGroup[groupName];
                                    serviceList.Add(serviceName);
                                }
                                else
                                {
                                    List <string> serviceList = new List <string>();
                                    serviceList.Add(serviceName);
                                    htServiceGroup.Add(groupName, serviceList);
                                }
                            }
                        }
                    }

                    servicesNameList.Sort();
                    foreach (string groupName in htServiceGroup.Keys)
                    {
                        string        text        = string.Format("{0}.  {1}", no++, groupName);
                        List <string> serviceList = (List <string>)htServiceGroup[groupName];
                        int           subNo       = 0;
                        foreach (string serviceName in serviceList)
                        {
                            text += string.Format("\n     {0}. {1}", GetSubNo(subNo++), serviceName);
                        }

                        dr = doc.Tables[1].Rows.Add(ref missing);
                        dr.Cells[1].Range.Text = text;
                        SetNormalText(dr.Cells[1].Range);
                    }

                    foreach (string serviceName in servicesNameList)
                    {
                        dr = doc.Tables[1].Rows.Add(ref missing);
                        dr.Cells[1].Range.Text = string.Format("{0}.  {1}", no++, serviceName);
                        SetNormalText(dr.Cells[1].Range);
                    }
                }

                dr = doc.Tables[1].Rows.Add(ref missing);
                dr.Cells[1].Range.Text = string.Format("Prescription (Toa thuốc) 	 Nội khoa	 Tai Mũi Họng	 Răng Hàm Mặt	 Sản phụ khoa");

                Microsoft.Office.Interop.Word.Row dr2 = doc.Tables[1].Rows.Add(ref missing);
                dr2.Cells[1].Range.Text = string.Format("{0}.  Others (Khác)", no);
                SetNormalText(dr2.Cells[1].Range);

                dr.Cells[1].Merge(dr.Cells[2]);
                dr.Height = dr.Height / 2.5f;
                dr.Cells[1].Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                SetNormalText(dr.Cells[1].Range);

                word.Visible = false;

                if (isPrint)
                {
                    word.ActivePrinter = printerName;

                    doc.PrintOut(ref missing, ref missing, ref missing, ref missing, ref missing,
                                 ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                                 ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                }
                else
                {
                    doc.Save();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (doc != null)
                {
                    doc.Close(ref missing, ref missing, ref missing);
                }
                if (word != null)
                {
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }
            }
        }
Esempio n. 7
0
        private void OnDisplayServicesList()
        {
            lock (ThisLock)
            {
                if (!_isViewAllDichVuHopDong)
                {
                    Result result = null;

                    if (!_isDichVuCon)
                    {
                        if (!_isServiceGroup)
                        {
                            result = ServicesBus.GetServicesListNotInCheckList(_contractGUID, _companyMemberGUID, _name);
                        }
                        else
                        {
                            result = ServiceGroupBus.GetServiceListNotInGroup(_name);
                        }
                    }
                    else if (_isDichVuHopDong)
                    {
                        result = ServicesBus.GetDichVuHopDongList(_name, _contractGUID);
                    }
                    else
                    {
                        result = ServicesBus.GetServicesList(_name);
                    }

                    if (result.IsOK)
                    {
                        dgService.Invoke(new MethodInvoker(delegate()
                        {
                            ClearData();

                            DataTable dt = result.QueryResult as DataTable;
                            dt           = GetDataSource(dt);
                            if (_dtTemp == null)
                            {
                                _dtTemp = dt.Clone();
                            }
                            UpdateChecked(dt);
                            dgService.DataSource = dt;
                        }));
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServicesBus.GetServicesListNotInCheckList"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ServicesBus.GetServicesListNotInCheckList"));
                    }
                }
                else
                {
                    dgService.Invoke(new MethodInvoker(delegate()
                    {
                        ClearData();

                        DataTable dt = _giaDichVuDataSource.Copy();
                        if (_dtTemp == null)
                        {
                            _dtTemp = dt.Clone();
                        }
                        UpdateChecked(dt);
                        dgService.DataSource = dt;
                    }));
                }
            }
        }
Esempio n. 8
0
        private bool CheckInfo()
        {
            if (txtCode.Text.Trim() == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng nhập mã nhóm dịch vụ.", IconType.Information);
                txtCode.Focus();
                return(false);
            }

            if (txtName.Text.Trim() == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng nhập tên nhóm dịch vụ.", IconType.Information);
                txtName.Focus();
                return(false);
            }

            string serviceGroupGUID = _isNew ? string.Empty : _serviceGroup.ServiceGroupGUID.ToString();
            Result result           = ServiceGroupBus.CheckServiceGroupExistCode(serviceGroupGUID, txtCode.Text);

            if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST)
            {
                if (result.Error.Code == ErrorCode.EXIST)
                {
                    MsgBox.Show(this.Text, "Mã nhóm dịch vụ này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information);
                    txtCode.Focus();
                    return(false);
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ServiceGroupBus.CheckServiceGroupExistCode"), IconType.Error);
                return(false);
            }

            if (dgService.RowCount <= 0)
            {
                MsgBox.Show(this.Text, "Vui lòng chọn ít nhất 1 dịch vụ.", IconType.Information);
                return(false);
            }

            foreach (string serviceGUID in _addedServices)
            {
                result = ServiceGroupBus.CheckServiceExist(serviceGUID);

                if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST)
                {
                    if (result.Error.Code == ErrorCode.EXIST)
                    {
                        string serviceName = GetServiceName(serviceGUID);
                        MsgBox.Show(this.Text, string.Format("Dịch vụ: '{0}' đã thuộc 1 nhóm khác.", serviceName), IconType.Information);

                        DataTable dt = dgService.DataSource as DataTable;
                        if (dt != null)
                        {
                            DataRow[] rows = dt.Select(string.Format("ServiceGUID='{0}'", serviceGUID));
                            if (rows != null && rows.Length > 0)
                            {
                                _addedServices.Remove(rows[0]["ServiceGUID"].ToString());
                                dt.Rows.Remove(rows[0]);
                            }
                        }

                        return(false);
                    }
                }
                else
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("ServiceGroupBus.CheckServiceExist"), IconType.Error);
                    return(false);
                }
            }

            return(true);
        }