Beispiel #1
0
        //public static List<Document> GetImage()
        //{
        //    {
        //        try
        //        {
        //            List<Document> documents = new List<Document>();
        //            DataRowCollection drc = SqlDataAccess.ExecuteDatasetSP("TDocuments_OfIMAGE_SLCT").Tables[0].Rows;
        //            foreach (DataRow dr in drc)
        //            {
        //                documents.Add(ObjectGenerator<Document>.GeneratFromDataRow(dr));

        //            }
        //            return documents;
        //        }
        //        catch (Exception ex)
        //        {
        //            Log.LogError("GetDocuments / TDocuments_OfStudents_SLCT", ", ex " + ex);
        //            return null;
        //        }



        public static int SetDocument(Document document, string nvBase64File, int iUserId)
        {
            try
            {
                if (nvBase64File != "")
                {
                    document.nvDocumentName = Fileshandler.SaveFileByBase64(nvBase64File, document.nvDocumentName);
                    if (document.iDocumentId != 0)
                    {
                        DataRow dr       = SqlDataAccess.ExecuteDatasetSP("TDocuments_ByDocumentId_SLCT", new SqlParameter("iDocumentId", document.iDocumentId)).Tables[0].Rows[0];
                        string  prevName = ObjectGenerator <Document> .GeneratFromDataRow(dr).nvDocumentName;

                        Fileshandler.DeleteFile(prevName);
                    }
                }
                List <SqlParameter> sqlParameters = ObjectGenerator <Document> .GetSqlParametersFromObject(document);

                sqlParameters.Add(new SqlParameter("iUserId", iUserId));

                var dtCreatedate = sqlParameters.Where(s => s.ParameterName.Equals("dtCreatedate")).FirstOrDefault();
                sqlParameters.Remove(dtCreatedate);
                //SqlDataAccess.ExecuteDatasetSP("TDocuments_INS/UPD", sqlParameters);

                //return true;

                int id = int.Parse(SqlDataAccess.ExecuteDatasetSP("TDocuments_INS/UPD", sqlParameters).Tables[0].Rows[0][0].ToString());
                return(id);
            }
            catch (Exception ex)
            {
                Log.LogError("SetDocument /TDocuments_INS/upd", "ex: " + ex);
                return(0);
            }
        }
Beispiel #2
0
        public static bool UpdateStudent(Student student, string base64Image, int iUserId)
        {
            try
            {
                if (base64Image != "")
                {
                    student.nvImgStudent = Fileshandler.SaveFileByBase64(base64Image, student.nvImgStudent, "Students//");
                    DataRow dr       = SqlDataAccess.ExecuteDatasetSP("TStudentGetStudentbyId_SLCT", new SqlParameter("iPersonId", student.iPersonId)).Tables[0].Rows[0];
                    string  prevName = ObjectGenerator <Student> .GeneratFromDataRow(dr).nvImgStudent;

                    if (prevName != "")
                    {
                        Fileshandler.DeleteFile(prevName, "Students//");
                    }
                }

                List <SqlParameter> parameters = ObjectGenerator <Student> .GetSqlParametersFromObject(student);

                parameters.Add(new SqlParameter("iUserId", iUserId));
                SqlDataAccess.ExecuteDatasetSP("TStudent_UPD", parameters);
                return(true);
            }
            catch (Exception ex)
            {
                Log.LogError("UpdateStudent / TStudent_UPD", "ex" + ex);
                return(false);
            }
        }
Beispiel #3
0
        public static bool AddStudent(Student student, string base64Image, int iUserId)
        {
            try
            {
                if (base64Image != "")
                {
                    student.nvImgStudent = Fileshandler.SaveFileByBase64(base64Image, student.nvImgStudent, "Students//");
                }
                List <SqlParameter> parameters = ObjectGenerator <Student> .GetSqlParametersFromObject(student);

                parameters.Add(new SqlParameter("iUserId", iUserId));
                SqlDataAccess.ExecuteDatasetSP("TStudent_INS", parameters);

                return(true);
            }
            catch (Exception ex)
            {
                Log.LogError("AddStudent / TStudent_INS", "ex" + ex);
                return(false);
            }
        }
 public string GeneratPdf(string headerHtml, string bodyHtml, string footerHtml)
 {
     return(Fileshandler.GeneratPdf(headerHtml, bodyHtml, footerHtml));
 }
 public string SaveFileByBase64(string base64File, string fileName)
 {
     return(Fileshandler.SaveFileByBase64(base64File, fileName));
 }
        public static int InsertUpdateRecommendation(Recommendation recommendation)
        {
            try
            {
                string procedureName = "TRecommendation_INS_UPD";
                Log.LogInfo("recommendation name: " + recommendation.nvFirstName + " " + recommendation.nvLastName);
                if (recommendation.oCategoryItem.iCatItemId == 0)
                {
                    procedureName = "TRecommendation_INS_NewDoctor";
                    recommendation.oCategoryItem.bNew = true;
                    Log.LogInfo("recommendation.oCategoryItem.bNew: " + recommendation.oCategoryItem.bNew);
                    Log.LogInfo("recommendation.oCategoryItem.iCatItemParentId: " + recommendation.oCategoryItem.iCatItemParentId);
                    recommendation.oCategoryItem = CategoryItem.InsertUpdateCategoryItem(1, recommendation.oCategoryItem);                    //TODO: change iUserId = 1
                    if (recommendation.oCategoryItem == null)
                    {
                        return(-1);
                    }
                }
                if (recommendation.iFlexibilityType <= 3 && recommendation.iFlexibilityType > 0)
                {
                    recommendation.iFlexibilityType += 3;
                }
                if (recommendation.iHumanityType <= 3 && recommendation.iHumanityType > 0)
                {
                    recommendation.iHumanityType += 3;
                }
                if (recommendation.iKindnessType <= 3 && recommendation.iKindnessType > 0)
                {
                    recommendation.iKindnessType += 3;
                }

                recommendation.iCatItemId = recommendation.oCategoryItem.iCatItemId;
                Log.LogInfo("recommendation.iCatItemId:" + recommendation.iCatItemId);
                if (recommendation.nvFilePath != null && recommendation.nvFilePath.IndexOf("data:") != -1)
                {
                    string path = recommendation.nvFilePath.Substring(recommendation.nvFilePath.IndexOf("data:"));
                    string name = recommendation.nvFilePath.IndexOf("name:") != -1 ? recommendation.nvFilePath.Substring(recommendation.nvFilePath.IndexOf("name:") + 5, recommendation.nvFilePath.IndexOf(";") - 5) : "";
                    recommendation.nvFilePath = Fileshandler.SaveFileByBase64(path, name);
                }
                //Log.LogInfo("recommendation.nvFilePath: " + recommendation.nvFilePath);
                DataSet ds = SqlDataAccess.ExecuteDatasetSP(procedureName, ObjectGenerator <Recommendation> .GetSqlParametersFromObject(recommendation));
                int     iRecommendationId = 0;
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    iRecommendationId = int.Parse(ds.Tables[0].Rows[0][0].ToString());
                }
                else
                {
                    return(iRecommendationId);
                }
                if (recommendation.nvMail != null && recommendation.nvMail != "")
                {
                    //SendMessage.SendEmailOrFax("", recommendation.nvMail, "פרס דניאלי", "תודה על השתתפותך במיזם פרס דניאלי - רפואה עם לב");
                    SendMessage.SendEmail(recommendation.nvMail).Wait();
                }
                Log.LogInfo("recommendation.nvMail: " + recommendation.nvMail);
                return(iRecommendationId);
            }
            catch (Exception ex)
            {
                Log.LogError("InsertUpdateRecommendation / TRecommendation_INS_UPD",
                             //"recommendation = " + JsonConvert.SerializeObject(recommendation) +
                             ", exception = " + ex);
                return(-1);
            }
        }