コード例 #1
0
        public static ClientModel Build(int ClientId, DASEntities db)
        {
            //ClientModel model = new ClientModel();
            ClientModel model = db.Clients.Where(a => a.ClientId == ClientId).Select(a => new ClientModel()
            {
                ClientName = a.Name, Description = a.Description, Address = a.Address, ClientId = a.ClientId
            }).FirstOrDefault();

            model.Certificates = new List <CertModel>();

            IList <Certificate> certs = db.Certificates.Where(j => j.ClientId == ClientId).ToList();
            CertModel           temp;

            foreach (var item in certs)
            {
                temp = new CertModel()
                {
                    CertId = item.CertificateId, CertName = item.CertificateName, Standard = item.Standard
                };
                temp.Status   = GetStatusName(db, item.StatusId);
                temp.Statuses = BuildStatuses(db);
                temp.StatusID = item.StatusId;

                model.Certificates.Add(temp);
            }
            return(model);
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: romulus0305/INI
        public JsonResult AddCertificate(int clientId, string certName, string standard, int statusId)
        {
            /*ModelState.Clear();*/
            Certificate cert;

            cert = new Certificate();
            cert.CertificateId   = Db.Certificates.Select(j => j.CertificateId).Max() + 1;
            cert.CertificateName = certName;
            cert.ClientId        = clientId;
            cert.Standard        = standard;
            cert.StatusId        = statusId;
            Db.Certificates.Add(cert);
            Db.SaveChanges();

            IList <CertModel> model = new List <CertModel>();

            IList <Certificate> certs = Db.Certificates.Where(j => j.ClientId == cert.ClientId).ToList();
            CertModel           temp;

            foreach (var item in certs)
            {
                temp = new CertModel()
                {
                    CertId = item.CertificateId, CertName = item.CertificateName, Standard = item.Standard
                };
                temp.Status   = ClientDetailsBuilder.GetStatusName(Db, item.StatusId);
                temp.StatusID = item.StatusId;
                model.Add(temp);
            }

            return(Json(ResponseStatus.Success, new { html = RenderPartialViewToString("Certificate", model) }));
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: romulus0305/INI
        public JsonResult SaveCerftificate(int certId, string certName, string standard, int statusId)
        {
            Certificate       c     = Db.Certificates.Where(j => j.CertificateId == certId).FirstOrDefault();
            IList <CertModel> model = new List <CertModel>();

            c.CertificateName = certName;
            c.Standard        = standard;
            c.StatusId        = statusId;
            Db.SaveChanges();

            IList <Certificate> certs = Db.Certificates.Where(j => j.ClientId == c.ClientId).ToList();
            CertModel           temp;

            foreach (var item in certs)
            {
                temp = new CertModel()
                {
                    CertId = item.CertificateId, CertName = item.CertificateName, Standard = item.Standard
                };
                temp.Status   = ClientDetailsBuilder.GetStatusName(Db, item.StatusId);
                temp.StatusID = item.StatusId;
                model.Add(temp);
            }


            return(Json(ResponseStatus.Success, new { html = RenderPartialViewToString("Certificate", model) }));
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: romulus0305/INI
        public ActionResult AddCertificateEditor()
        {
            CertModel model = new CertModel();

            model.Statuses = ClientDetailsBuilder.BuildStatuses(Db);
            return(Json(ResponseStatus.Success, RenderPartialViewToString("AddCertificate", model), JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
 private void CertDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == CertDataGridView.Columns["ViewStudentImage"].Index && e.RowIndex >= 0)
     {
         int       certId    = int.Parse(CertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
         CertModel certModel = managingCertService.GetSingleCertById(certId);
         string    imageName = managingStudentService.GetStudentImage(certModel.StudentId);
         if (string.IsNullOrEmpty(imageName))
         {
             //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Cảnh báo", MessageBoxIcon.Warning);
             notificationForm.ShowDialog();
             return;
         }
         string           path             = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
         ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\StudentImages\", imageName));
         showingImageForm.ShowDialog();
     }
     else if (e.ColumnIndex == CertDataGridView.Columns["ViewBlankCertImage"].Index && e.RowIndex >= 0)
     {
         int       certId    = int.Parse(CertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
         CertModel certModel = managingCertService.GetSingleCertById(certId);
         string    imageName = managingBlankCertService.GetBlankCertImage(certModel.BlankCertId);
         if (string.IsNullOrEmpty(imageName))
         {
             //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Cảnh báo", MessageBoxIcon.Warning);
             notificationForm.ShowDialog();
             return;
         }
         string           path             = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
         ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\Images\", imageName));
         showingImageForm.ShowDialog();
     }
 }
コード例 #6
0
ファイル: HomeController.cs プロジェクト: romulus0305/INI
        public JsonResult EditCertificate(int certId)
        {
            Certificate c     = Db.Certificates.Where(j => j.CertificateId == certId).FirstOrDefault();
            CertModel   model = new CertModel()
            {
                CertId = c.CertificateId, CertName = c.CertificateName, Standard = c.Standard, StatusID = c.StatusId
            };

            model.Statuses = ClientDetailsBuilder.BuildStatuses(Db);


            return(Json(ResponseStatus.Success, new { html = RenderPartialViewToString("EditCertificate", model) }));
        }
コード例 #7
0
        /// <summary>
        /// 初始化请求
        /// </summary>
        /// <param name="request"></param>
        private void InitRequest(HttpWebRequest request)
        {
            //设置安全请求模式
            if (request.RequestUri.ToString().ToLower().StartsWith("https:"))
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
            }

            //添加cookie
            CookieModel.SetCookies(request);

            //添加证书
            CertModel?.SetCert(request);

            //超时时间
            request.Timeout = Timeout;
        }
コード例 #8
0
 private void LoadCertList()
 {
     CertDataGridView.Rows.Clear();
     foreach (var certId in _certIds)
     {
         CertModel certModel = managingCertService.GetSingleCertById(certId);
         int       i         = 1;
         CertDataGridView.Rows.Add
         (
             certModel.IsPrinted,
             certModel.Id,
             i++,
             certModel.StudentName,
             certModel.SchoolName,
             certModel.Serial,
             certModel.ReferenceNumber
         );
     }
 }
コード例 #9
0
        private void Pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            int                  certId               = int.Parse(((PrintDocument)sender).DocumentName);
            CertModel            certModel            = managingCertService.GetSingleCertById(certId);
            StudentModel         studentModel         = managingStudentService.GetSingleStudentById(certModel.StudentId);
            BlankCertConfigModel blankCertConfigModel = managingBlankCertConfigService.GetSingleByBlankCertType(blankCertTypeId);
            //Get the Graphics object
            Graphics g = e.Graphics;

            //Create a font Arial with size 16
            Font font = new Font("Arial", 16);

            //Create a solid brush with black color
            SolidBrush brush = new SolidBrush(Color.Black);

            if (blankCertTypeId == (int)Common.BlankCertType.HightSchool)
            {
                //g.DrawString("Hanhsama " + certId,
                //   font, brush,
                //   new Rectangle(20, 70, 200, 100));

                //g.DrawString(studentModel.GraduatingYear.ToString(),
                //   font, brush,
                //   new Rectangle(blankCertConfigModel., 200, 100));
                // thieu graduating year trong blankcertconfig
            }
            else if (blankCertTypeId == (int)Common.BlankCertType.JuniorHighSchool)
            {
            }
            else if (blankCertTypeId == (int)Common.BlankCertType.University)
            {
            }
            else if (blankCertTypeId == (int)Common.BlankCertType.Master)
            {
            }
        }
コード例 #10
0
        private void EditCertForm_Load(object sender, EventArgs e)
        {
            try
            {
                // load school
                SchoolComboBox.DataSource    = managingSchoolService.GetAllSchool();
                SchoolComboBox.DisplayMember = "SchoolName";
                SchoolComboBox.ValueMember   = "Id";

                // load ethnic
                EthnicComboBox.DataSource    = managingStudentService.GetAllEthnic();
                EthnicComboBox.DisplayMember = "EthnicName";
                EthnicComboBox.ValueMember   = "Id";

                // load ranking
                RankingComboBox.DataSource    = managingStudentService.GetAllRanking();
                RankingComboBox.DisplayMember = "RankingName";
                RankingComboBox.ValueMember   = "Id";

                // load gender
                GenderComboBox.Items.Add("Nam");
                GenderComboBox.Items.Add("Nữ");

                // load major
                List <MajorModel> majorModels = managingStudentService.GetAllMajor();
                majorModels.Add(new MajorModel()
                {
                    Id        = -1,
                    MajorName = "Không có chuyên ngành"
                });
                MajorComboBox.DataSource    = majorModels;
                MajorComboBox.DisplayMember = "MajorName";
                MajorComboBox.ValueMember   = "Id";

                // load learning Mode
                LearningModeComboBox.DataSource    = managingStudentService.GetAllLearningMode();
                LearningModeComboBox.DisplayMember = "LearningModeName";
                LearningModeComboBox.ValueMember   = "Id";


                certModel    = managingCertService.GetSingleCertById(_certId);
                studentModel = managingStudentService.GetSingleStudentById(certModel.StudentId);

                FullnameTextBox.Text         = studentModel.FullName;
                SchoolComboBox.SelectedValue = studentModel.SchoolId;
                BornedAddressTextBox.Text    = studentModel.BornedAddress;
                AddressTextBox.Text          = studentModel.Address;
                DobTextBox.Text                    = studentModel.Dob.ToString("dd/MM/yyyy");
                HouseHoldTextBox.Text              = studentModel.HouseHold;
                ScoreTextBox.Text                  = studentModel.Score.ToString();
                GraduatingYearTextBox.Text         = studentModel.GraduatingYear.ToString();
                RankingComboBox.SelectedValue      = studentModel.RankingId;
                MajorComboBox.SelectedValue        = studentModel.MajorId;
                LearningModeComboBox.SelectedValue = studentModel.LearningModeId;
                EthnicComboBox.SelectedValue       = studentModel.EthnicId;
                GenderComboBox.SelectedItem        = studentModel.Gender;

                SerialTextBox.Text          = certModel.Serial;
                ReferenceNumberTextBox.Text = certModel.ReferenceNumber;

                // load student image
                string imageName = managingStudentService.GetStudentImage(certModel.StudentId);
                if (string.IsNullOrEmpty(imageName))
                {
                    //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Lỗi", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                using (FileStream fs = new FileStream(Path.Combine(@"C:\JbCert_Resource\StudentImages\", imageName), FileMode.Open))
                {
                    StudentImagePictureBox.Image = Image.FromStream(fs);
                }

                // load blankcert image
                imageName = managingBlankCertService.GetBlankCertImage(certModel.BlankCertId);
                if (string.IsNullOrEmpty(imageName))
                {
                    //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Lỗi", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                using (FileStream fs = new FileStream(Path.Combine(@"C:\JbCert_Resource\Images\", imageName), FileMode.Open))
                {
                    BlankCertImagePictureBox.Image = Image.FromStream(fs);
                }
            }
            catch (FileNotFoundException FileNotFoundEx)
            {
                NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh, vui lòng cập nhật lại ảnh", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
コード例 #11
0
        public static ClientList FilterClients(DASEntities db, GridDescriptor desc, FilterModel filters)
        {
            ClientList model = new ClientList()
            {
                Descriptor = desc, ListOfClients = new List <ClientModel>()
            };
            IQueryable <Client> clients = db.Clients.AsQueryable();
            IQueryable <vw_ClientsBackoffice> clientsF = db.vw_ClientsBackoffice.AsQueryable();
            string filStandard = "";

            if (filters == null)
            {
                filters = new FilterModel();
            }


            if (!string.IsNullOrWhiteSpace(filters.Name))
            {
                filStandard = filters.Name.Replace(":", "").Replace("/", "").Replace("-", "").Replace("–", "").Replace("\"", "").Replace(".", "");
                clientsF    = clientsF.Where(m => m.Name.Contains(filStandard));
            }


            if (filters.SelectedStatusId != 0)
            {
                if (!string.IsNullOrWhiteSpace(filters.Standard))
                {
                    clientsF = clientsF.Where(b => b.StatusId == filters.SelectedStatusId && b.Standard.Contains(filters.Standard));
                }
                else
                {
                    clientsF = clientsF.Where(m => m.StatusId == filters.SelectedStatusId);
                }
            }
            else if (!string.IsNullOrWhiteSpace(filters.Standard))
            {
                clientsF = clientsF.Where(m => m.Standard.Contains(filters.Standard));
            }

            IList <int> clientIds = clientsF.Select(k => k.ClientId).Distinct().ToList();


            IList <Client> listC = clients.Where(h => clientIds.Contains(h.ClientId)).Slice(desc).ToList();
            ClientModel    clientM;
            CertModel      certM;

            foreach (var item in listC)
            {
                clientM = new ClientModel()
                {
                    ClientId = item.ClientId, Address = item.Address, ClientName = item.Name, Description = item.Description, Certificates = new List <CertModel>()
                };
                foreach (var itemC in item.Certificates)
                {
                    if ((string.IsNullOrWhiteSpace(filters.Standard) || itemC.Standard.Contains(filters.Standard.ToUpper())) && (filters.SelectedStatusId == 0 || filters.SelectedStatusId == itemC.StatusId))
                    {
                        certM = new CertModel()
                        {
                            CertId = itemC.CertificateId, CertName = itemC.CertificateName, Standard = itemC.Standard
                        };
                        certM.Status = GetStatusName(db, itemC.StatusId);
                        clientM.Certificates.Add(certM);
                    }
                }
                model.ListOfClients.Add(clientM);
            }
            return(model);
        }
コード例 #12
0
        public static ClientsModel BuildClients(DASEntities db)
        {
            ClientsModel model      = new ClientsModel();
            int          languageId = (int)HttpContext.Current.Session["lngId"];

            model.Filters = new FilterModel();

            model.Filters.Statuses = BuildStatuses(db);
            /*todo; dodati labelu Svi u labels*/

            string stat = "...";

            stat = db.Labels.Where(s => s.ViewId == "Clients" && s.ElementId == "lblSearchStat" && s.LanguageId == languageId).Select(ps => ps.Text).FirstOrDefault();

            model.Filters.Statuses.Add(new StatusModel()
            {
                StatusId = 0, StatusName = stat
            });
            /*in backoffice selected status is All*/
            model.Filters.SelectedStatusId = 0;
            model.Filters.Statuses         = model.Filters.Statuses.OrderBy(m => m.StatusId).ToList();

            GridDescriptor desc = new GridDescriptor(new SortDescriptor()
            {
                PropertyName = "DateChange", Order = SortOrder.Descending
            })
            {
                Pager = new PagerDescriptor(1, 20, db.Labels.Where(l => l.ViewId == "Clients" && l.ElementId == "lblPageSize" && l.LanguageId == languageId).Select(l => l.Text).FirstOrDefault(), 5)
            };

            IQueryable <Client> clients = db.Clients.AsQueryable();

            /*initial filter will be only with active status*/
            //clients = clients.Where(m => m.Certificates.Any(l => l.StatusId == 1));
            IList <Client> listC = clients.Slice(desc).ToList();

            model.Clients = new ClientList()
            {
                Descriptor = desc, ListOfClients = new List <ClientModel>()
            };
            ClientModel clientM;
            CertModel   certM;

            foreach (var item in listC)
            {
                clientM = new ClientModel()
                {
                    ClientId = item.ClientId, Address = item.Address, ClientName = item.Name, Description = item.Description, Certificates = new List <CertModel>()
                };
                foreach (var itemC in item.Certificates)
                {
                    //if (itemC.StatusId==1)
                    //{
                    certM = new CertModel()
                    {
                        CertId = itemC.CertificateId, CertName = itemC.CertificateName, Standard = itemC.Standard
                    };
                    certM.Status = GetStatusName(db, itemC.StatusId);
                    clientM.Certificates.Add(certM);
                    //}
                }
                model.Clients.ListOfClients.Add(clientM);
            }
            return(model);
        }
コード例 #13
0
        public List <CertModel> GetAll()
        {
            List <CertModel> certModels = new List <CertModel>();

            using (conn = JBCertConnection.Instance)
            {
                string queryString = @"SELECT a.*, b.Ten as 'Hovaten', b.TruongId , f.Tentruong ,c.Tenxeploai, d.Serial as 'Sohieu', d.LoaiId, e.Name as 'Tenloai' 
                                      FROM [dbo].[tblBang] as a
                                      left join [dbo].[tblHocsinh] as b
                                      on a.HocsinhId = b.Id
                                      Left join [dbo].[tblXeploai] as c
                                      on a.XeploaiId = c.Id
                                      left join [dbo].[tblPhoi] as d
                                      on a.PhoiId = d.Id
                                      left join [dbo].[tblLoai] as e
                                      on d.LoaiId = e.Id
									  left join [dbo].[tblTruong] as f
									  on b.TruongId = f.Id
                                      where a.isdeleted = 0";
                conn.Open();

                SqlCommand sqlCommand = new SqlCommand(queryString, conn);
                sqlCommand.CommandType = CommandType.Text;
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                try
                {
                    while (sqlDataReader.Read())
                    {
                        CertModel certModel = new CertModel();
                        certModel.Id                     = int.Parse(sqlDataReader["Id"].ToString());
                        certModel.StudentId              = int.Parse(sqlDataReader["HocsinhId"].ToString());
                        certModel.StudentName            = sqlDataReader["Hovaten"].ToString();
                        certModel.RankingId              = int.Parse(sqlDataReader["XeploaiId"].ToString());
                        certModel.RankingName            = sqlDataReader["Tenxeploai"].ToString();
                        certModel.CertName               = sqlDataReader["Tenbang"].ToString();
                        certModel.BlankCertId            = int.Parse(sqlDataReader["PhoiId"].ToString());
                        certModel.Serial                 = sqlDataReader["Sohieu"].ToString();
                        certModel.SchoolId               = int.Parse(sqlDataReader["TruongId"].ToString());
                        certModel.SchoolName             = sqlDataReader["Tentruong"].ToString();
                        certModel.ReferenceNumber        = sqlDataReader["Sovaoso"].ToString();
                        certModel.ProviderName           = sqlDataReader["Tennguoicap"].ToString();
                        certModel.Position               = sqlDataReader["Chucvu"].ToString();
                        certModel.GrantedDate            = DateTime.Parse(sqlDataReader["Ngaycap"].ToString());
                        certModel.ManagementAddress      = sqlDataReader["Noiquanly"].ToString();
                        certModel.ReceiverName           = sqlDataReader["Nguoinhan"].ToString();
                        certModel.ReceiverIdentityNumber = sqlDataReader["CMTnguoinhan"].ToString();
                        certModel.Note                   = sqlDataReader["Ghichu"].ToString();
                        certModel.IsGranted              = bool.Parse(sqlDataReader["IsGranted"].ToString());
                        certModel.IsPrinted              = bool.Parse(sqlDataReader["IsPrinted"].ToString());
                        certModel.IsDeleted              = false;

                        certModels.Add(certModel);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    sqlDataReader.Close();
                    conn.Close();
                }
            }

            return(certModels);
        }