public static string WebRequestMethod(string URL, string Body, string Method = "POST", string ContentType = "application/json;charset=utf-8") { try { WebRequest request = WebRequest.Create(URL); request.Method = Method; request.ContentType = ContentType; if (Method == "POST") { using (Stream SRequest = request.GetRequestStream()) { using (StreamWriter SW = new StreamWriter(SRequest)) SW.Write(Body); } } //get response-stream, and use a streamReader to read the content using (Stream SResponse = request.GetResponse().GetResponseStream()) { using (StreamReader SR = new StreamReader(SResponse)) { return(SR.ReadToEnd()); } } } catch (Exception er) { DALC.ErrorLogsInsert(string.Format("DALC_Adoption.WebRequestMethod catch error: {0}", er.Message)); throw new Exception(er.Message); } }
protected void Page_Load(object sender, EventArgs e) { //Login control if (DALC._GetUsersLogin == null) { Config.Redirect("/?return=" + Request.Url.ToString()); return; } string UserControlName = ""; if (Config._GetQueryString("p").Length > 0) { UserControlName += Config._GetQueryString("p"); MultiView1.ActiveViewIndex = 1; try { PanelControl.Controls.Add(Page.LoadControl("controls/" + UserControlName + ".ascx")); } catch (Exception er) { DALC.ErrorLogsInsert("Reports - User control tapilmadi: Catch error: " + er.Message); Response.Write("Xəta: " + er.Message); Response.End(); } } }
public static object _RowsObject(this System.Data.DataTable Dt, string ColumnsName, int RowsIndex = 0) { if (Dt.Rows == null || Dt.Rows.Count < 1) { DALC.ErrorLogsInsert("Rows null or count error. ColumnsName: " + ColumnsName); throw new Exception("Rows null or count error. ColumnsName: " + ColumnsName); } else { return(Dt.Rows[RowsIndex][ColumnsName]); } }
/// Decrypts an encrypted text block public static string Decrypt(this string textToDecrypt) { try { TripleDESImplementation("fblsQBxfNs6nQ10wsRcMFwCN", "25ywte53"); byte[] buffer = Convert.FromBase64String(textToDecrypt); TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); des.Key = EncryptionKey; des.IV = Global_IV; return(UTF8Encoding.UTF8.GetString(des.CreateDecryptor().TransformFinalBlock(buffer, 0, buffer.Length))); } catch (Exception er) { DALC.ErrorLogsInsert("Cryptography.Decrypt catch error: (Text: " + textToDecrypt + ") " + er.Message + " | Url: " + HttpContext.Current.Request.Url.ToString()); return(""); } }
public static bool ImgResize(string Path, int Width, int Height, System.IO.Stream StreamFileupload, long ImgQuality) { try { //Thumbnain yaradaq, şəkil təmizliyi maksimum olacaq. *************************** string thumbnailFilePath = string.Empty; using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(StreamFileupload)) { thumbnailFilePath = HttpContext.Current.Server.MapPath(Path); //Save File System.Drawing.Size newSize = new System.Drawing.Size(Width, Height); // Thumbnail ölçüsü (width = xxx) (height = xxx) using (System.Drawing.Bitmap thumb = new System.Drawing.Bitmap((System.Drawing.Image)bmp, newSize)) { using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumb)) // Original şəkili grafikə çeviririk: Təmizləmək üçün { //Təmizlik paramterləri: g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; //Şəkil Codec yaradırıq. Sondakı 1 index dəyəridir. System.Drawing.Imaging.ImageCodecInfo codec = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[1]; //Encoding paramter maksimum 100L gedir o zaman şəkilin həcmi çox olur. System.Drawing.Imaging.EncoderParameters eParams = new System.Drawing.Imaging.EncoderParameters(1); eParams.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, ImgQuality); //Şəkili yaradırıq və dəyərlərini üstəki kimi daxil edirik. g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, thumb.Width, thumb.Height)); //Son olaraq Save edirik: thumb.Save(thumbnailFilePath, codec, eParams); return(true); } } } } catch (Exception er) { DALC.ErrorLogsInsert("Şəkil ölçüləndirmədə xəta baş verdi catch error: " + er.Message + ", path: " + Path); return(false); } }
//sekilleri yukle private void BindImage() { if (!FileUploadFiles.HasFile) { return; } DateTime Date = DateTime.Now; string AllowType = "-jpg-jpeg-png-"; string FileType = FileUploadFiles.PostedFile.FileName.GetExtension(); string FileName = Config.ClearTitle(System.IO.Path.GetFileNameWithoutExtension(FileUploadFiles.PostedFile.FileName)) + "." + FileType; string SavePath = path + ChildID + ".jpg"; if (AllowType.IndexOf(FileType) < 0) { Config.MsgBoxAjax("Faylın növü uyğun gəlmir. Yalnız : " + AllowType, Page); return; } if (!FileUploadFiles.PostedFile.CheckFileContentLength()) { Config.MsgBoxAjax("Faylın həcmi ən çox 10 MB ola bilər.", Page); return; } try { FileUploadFiles.SaveAs(Server.MapPath(SavePath)); } catch { DALC.ErrorLogsInsert("AdoptionPersonOperations-da şəkili yukledikde xeta bash verdi."); return; } }
protected void Page_Load(object sender, EventArgs e) { if (DALC_Adoption._GetAdoptionAdministratorsLogin == null) { Config.Redirect("/adminn/?return=" + Request.Url.ToString()); return; } string UserControlName = "main"; if (Config._GetQueryString("p").Length > 0) { UserControlName = Config._GetQueryString("p"); } try { PanelControl.Controls.Add(Page.LoadControl(UserControlName + ".ascx")); } catch (Exception er) { DALC.ErrorLogsInsert("Admin - User control tapilmadi: Catch error: " + er.Message); Response.Write("Xəta: " + er.Message); Response.End(); } }
protected void BtnConfirm_Click(object sender, EventArgs e) { lang = Config._GetQueryString("lang"); string ErrorMessage = ""; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "CallDatePicker", "CallDatePicker();", true); TxtName.CssClass = TxtSurname.CssClass = TxtMobileNumber.CssClass = TxtEmail.CssClass = "form-control form-inputs"; TxtBirthDate.CssClass = "form-control form_datetime form-inputs"; DListBirthPlace.CssClass = DListGender.CssClass = DListNationality.CssClass = DListChildAge.CssClass = DListChildGender.CssClass = "form-control input-filter form-inputs"; PnlAlert.Visible = false; #region Validations try { dynamic capthaResult = Newtonsoft.Json.Linq.JObject.Parse(DALC_Adoption.WebRequestMethod(string.Format(Config._GetAppSettings("GoogleCapthaValid").Decrypt(), Request["g-recaptcha-response"]._ToString(), Request.UserHostAddress), string.Empty)); if (!(bool)capthaResult.success) { if (lang == "az") { ErrorMessage = "Təhlükəsizlik qutusunu işarələyin."; } else if (lang == "ru") { ErrorMessage = "Təhlükəsizlik qutusunu işarələyin."; } else if (lang == "en") { ErrorMessage = "Please check the security box."; } PnlAlert.Visible = true; LtrAlert.Text = ErrorMessage; return; } } catch (Exception er) { DALC.ErrorLogsInsert(string.Format("Google captcha catch error TableName: {0} count xəta: {1}", "AdoptionForeign", er.Message)); Response.Write(Config._DefaultSystemErrorMessages); Response.End(); return; } if (string.IsNullOrEmpty(TxtName.Text)) { if (lang == "az") { ErrorMessage = "Adı qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Adı qeyd edin."; } else if (lang == "en") { ErrorMessage = "Please type the name."; } ErrorMessagesTextbox(TxtName, ErrorMessage); return; } if (string.IsNullOrEmpty(TxtSurname.Text)) { if (lang == "az") { ErrorMessage = "Soyadı qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Soyadı qeyd edin."; } else if (lang == "en") { ErrorMessage = "Please type the surname."; } ErrorMessagesTextbox(TxtSurname, ErrorMessage); return; } if (DListGender.SelectedValue == "-1") { if (lang == "az") { ErrorMessage = "Cins seçilməyib."; } else if (lang == "ru") { ErrorMessage = "Cins seçilməyib."; } else if (lang == "en") { ErrorMessage = "Cins seçilməyib."; } ErrorMessagesDropList(DListGender, ErrorMessage); return; } if (string.IsNullOrEmpty(TxtBirthDate.Text)) { if (lang == "az") { ErrorMessage = "Doğum tarixini qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Doğum tarixini qeyd edin."; } else if (lang == "en") { ErrorMessage = "Doğum tarixini qeyd edin."; } ErrorMessagesTextbox(TxtBirthDate, ErrorMessage); return; } if (Config.DateFormatClear(TxtBirthDate.Text) == null) { if (lang == "az") { ErrorMessage = "Doğum tarixini düzgün formatda daxil edin."; } else if (lang == "ru") { ErrorMessage = "Doğum tarixini düzgün formatda daxil edin."; } else if (lang == "en") { ErrorMessage = "Doğum tarixini düzgün formatda daxil edin."; } ErrorMessagesTextbox(TxtBirthDate, ErrorMessage); return; } if (DListBirthPlace.SelectedValue == "-1") { if (lang == "az") { ErrorMessage = "Doğum yerini qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Doğum yerini qeyd edin."; } else if (lang == "en") { ErrorMessage = "Doğum yerini qeyd edin."; } ErrorMessagesDropList(DListBirthPlace, ErrorMessage); return; } if (DListNationality.SelectedValue == "-1") { if (lang == "az") { ErrorMessage = "Vətəndaşlığı qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Vətəndaşlığı qeyd edin."; } else if (lang == "en") { ErrorMessage = "Vətəndaşlığı qeyd edin."; } ErrorMessagesDropList(DListNationality, ErrorMessage); return; } if (string.IsNullOrEmpty(TxtMobileNumber.Text)) { if (lang == "az") { ErrorMessage = "Əlaqə nömrəsini qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Əlaqə nömrəsini qeyd edin."; } else if (lang == "en") { ErrorMessage = "Əlaqə nömrəsini qeyd edin."; } ErrorMessagesTextbox(TxtMobileNumber, ErrorMessage); return; } if (!Config.IsNumeric(TxtMobileNumber.Text)) { if (lang == "az") { ErrorMessage = "Əlaqə nömrəsini düzgün formatda daxil edin."; } else if (lang == "ru") { ErrorMessage = "Əlaqə nömrəsini düzgün formatda daxil edin."; } else if (lang == "en") { ErrorMessage = "Əlaqə nömrəsini düzgün formatda daxil edin."; } ErrorMessagesTextbox(TxtMobileNumber, ErrorMessage); return; } if (string.IsNullOrEmpty(TxtEmail.Text)) { if (lang == "az") { ErrorMessage = "Elektron ünvanı qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Elektron ünvanı qeyd edin."; } else if (lang == "en") { ErrorMessage = "Elektron ünvanı qeyd edin."; } ErrorMessagesTextbox(TxtEmail, ErrorMessage); return; } if (!Config.IsEmail(TxtEmail.Text)) { if (lang == "az") { ErrorMessage = "Elektron ünvanı düzgün formatda daxil edin."; } else if (lang == "ru") { ErrorMessage = "Elektron ünvanı düzgün formatda daxil edin."; } else if (lang == "en") { ErrorMessage = "Elektron ünvanı düzgün formatda daxil edin."; } ErrorMessagesTextbox(TxtEmail, ErrorMessage); return; } if (DListChildAge.SelectedValue == "-1") { if (lang == "az") { ErrorMessage = "Uşağın yaşını qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Uşağın yaşını qeyd edin."; } else if (lang == "en") { ErrorMessage = "Uşağın yaşını qeyd edin."; } ErrorMessagesDropList(DListChildAge, ErrorMessage); return; } if (DListChildGender.SelectedValue == "-1") { if (lang == "az") { ErrorMessage = "Uşağın cinsini qeyd edin."; } else if (lang == "ru") { ErrorMessage = "Uşağın cinsini qeyd edin."; } else if (lang == "en") { ErrorMessage = "Uşağın cinsini qeyd edin."; } ErrorMessagesDropList(DListChildGender, ErrorMessage); return; } #endregion string GeneratedHtml = string.Format(LblName.Text.Replace(ImportantIcon, "") + TxtName.Text + "{0}" + LblSurname.Text.Replace(ImportantIcon, "") + TxtSurname.Text + "{0}" + LblPatronymic.Text + TxtPatronymic.Text + "{0}" + LblGender.Text.Replace(ImportantIcon, "") + DListGender.SelectedItem.Text + "{0}" + LblBirthDate.Text.Replace(ImportantIcon, "") + Config.DateFormatClear(TxtBirthDate.Text) + "{0}" + LblBirthPlace.Text.Replace(ImportantIcon, "") + DListBirthPlace.SelectedItem.Text + "{0}" + LblNationality.Text.Replace(ImportantIcon, "") + DListNationality.SelectedItem.Text + "{0}" + LblRegisteredAddress.Text.Replace(ImportantIcon, "") + TxtRegisteredAddress.Text + "{0}" + LblCurrentResidence.Text.Replace(ImportantIcon, "") + TxtCurrentResidence.Text + "{0}" + LblPhoneNumber.Text.Replace(ImportantIcon, "") + TxtPhoneNumber.Text + "{0}" + LblMobileNumber.Text.Replace(ImportantIcon, "") + TxtMobileNumber.Text + "{0}" + LblEmail.Text.Replace(ImportantIcon, "") + TxtEmail.Text + "{0}" + LblEducation.Text.Replace(ImportantIcon, "") + DListEducation.SelectedItem.Text + "{0}" + LblMarriedStatus.Text.Replace(ImportantIcon, "") + DListMarriedStatus.SelectedItem.Text + "<br/>" + "<strong>" + LtrSubTitle.Text + "</strong><br/>" + LblChildAge.Text.Replace(ImportantIcon, "") + DListChildAge.SelectedItem.Text + "{0}" + LblChildGender.Text.Replace(ImportantIcon, "") + DListChildGender.SelectedItem.Text + "{0}" + LblHealthStatus.Text.Replace(ImportantIcon, "") + DListHealthStatus.SelectedItem.Text + "{0}" + LblCause.Text.Replace(ImportantIcon, "") + TxtCause.Text, ",<br/>"); }
protected void BtnSave_Click(object sender, EventArgs e) { //eger istifadeci veya admin deyilse if (DALC._GetAdministratorsLogin.UsersStatusID != 30 && DALC._GetAdministratorsLogin.UsersStatusID != 25) { return; } if (string.IsNullOrEmpty(TxtNumbers.Text.Trim())) { Config.MsgBoxAjax("Fərdi şikayət nömrəsini daxil edin."); ShowPopup(); return; } if (!Config.IsNumeric(TxtNumbers.Text.Trim())) { Config.MsgBoxAjax("Fərdi şikayət nömrəsini rəqəm tipdə daxil edin."); ShowPopup(); return; } if (DListComplaintType.SelectedValue == "-1") { Config.MsgBoxAjax("Şikayətin mahiyyətini seçin."); ShowPopup(); return; } if (DlistExecutiveUsers.SelectedValue == "-1") { Config.MsgBoxAjax("İcraçını seçin."); ShowPopup(); return; } object DtEnterOrganizations = TxtEnterOrganizationsDt.Text.DateTimeFormat(); if (DtEnterOrganizations == null) { Config.MsgBoxAjax("Aparata daxil olma tarixini düzgün daxil edin."); ShowPopup(); return; } object DtEnterSector = TxtEnterSectorDt.Text.DateTimeFormat(); if (DtEnterSector == null) { Config.MsgBoxAjax("Sektora daxil olma tarixini düzgün daxil edin."); ShowPopup(); return; } if (string.IsNullOrEmpty(TxtApplicantsFullname.Text.Trim())) { Config.MsgBoxAjax("Ərizəçini daxil edin."); ShowPopup(); return; } if (string.IsNullOrEmpty(TxtApplicantsAddress.Text.Trim())) { Config.MsgBoxAjax("Ünvanını daxil edin."); ShowPopup(); return; } if (string.IsNullOrEmpty(TxtVictimsFullname.Text.Trim())) { Config.MsgBoxAjax("Kimin barəsində müraciət edildiyini daxil edin."); ShowPopup(); return; } if (DListApplicatsGenderType.SelectedValue == "-1") { Config.MsgBoxAjax("Cinsini daxil edin."); ShowPopup(); return; } if (string.IsNullOrEmpty(TxtComplaintInstitution.Text.Trim())) { Config.MsgBoxAjax("Şikayət olunan subyekti daxil edin."); ShowPopup(); return; } //if (string.IsNullOrEmpty(TxtQueriedInstitution.Text.Trim())) //{ // Config.MsgBoxAjax("Sorğu göndərilən orqanı daxil edin."); // ShowPopup(); // return; //} //if (string.IsNullOrEmpty(TxtQueriedRespond.Text.Trim())) //{ // Config.MsgBoxAjax("Sorğuya verilən cavabı daxil edin."); // ShowPopup(); // return; //} //if (string.IsNullOrEmpty(TxtCitizenRespond.Text.Trim())) //{ // Config.MsgBoxAjax("Vətəndaşa verilən cavabı daxil edin."); // ShowPopup(); // return; //} //if (string.IsNullOrEmpty(TxtResults.Text.Trim())) //{ // Config.MsgBoxAjax("Nəticəni daxil edin."); // ShowPopup(); // return; //} try { int result = -1; Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("ExecutiveUsersID", int.Parse(DlistExecutiveUsers.SelectedValue)); parameters.Add("ComplaintTypeID", int.Parse(DListComplaintType.SelectedValue)); parameters.Add("Numbers", TxtNumbers.Text._ToInt32()); parameters.Add("ApplicantsFullname", TxtApplicantsFullname.Text); parameters.Add("GenderTypeID", int.Parse(DListApplicatsGenderType.SelectedValue)); if (DListApplicantsSocialStatus.SelectedValue == "-1") parameters.Add("SocialStatusID", DBNull.Value); else parameters.Add("SocialStatusID", int.Parse(DListApplicantsSocialStatus.SelectedValue)); parameters.Add("VictimsFullname", TxtVictimsFullname.Text); parameters.Add("ApplicantsAddress", TxtApplicantsAddress.Text); parameters.Add("ComplaintInstitution", TxtComplaintInstitution.Text); parameters.Add("IsBadTreatment", ChkIsBadTreatment.Checked); parameters.Add("QueriedInstitution", TxtQueriedInstitution.Text); parameters.Add("QueriedRespond", TxtQueriedRespond.Text); parameters.Add("CitizenRespond", TxtCitizenRespond.Text); parameters.Add("IsReference", ChkIsReference.Checked); if (DListComplaintResultType.SelectedValue == "-1") parameters.Add("ComplaintResultTypeID", DBNull.Value); else parameters.Add("ComplaintResultTypeID", int.Parse(DListComplaintResultType.SelectedValue)); parameters.Add("Results", TxtResults.Text); parameters.Add("EnterOrganizations_Dt", (DateTime)DtEnterOrganizations); parameters.Add("EnterSector_Dt", (DateTime)DtEnterSector); if (ViewState["operation"]._ToString() == "new") { parameters.Add("CreatedUsersID", DALC._GetAdministratorsLogin.ID); parameters.Add("Add_Dt", DateTime.Now); parameters.Add("Add_Ip", HttpContext.Current.Request.UserHostAddress.IPToInteger()); result = DALC.InsertDatabase("IndividualComplaints", parameters); } else if (ViewState["operation"]._ToString() == "edit") { parameters.Add("WhereId", ViewState["IndividualComplaintsId"]._ToString()); result = DALC.UpdateDatabase("IndividualComplaints", parameters); } if (result > 0) { Config.MsgBoxAjax(ViewState["operation"]._ToString() == "new" ? "Məlumatlar qeydə alındı." : "Məlumatlar redaktə edildi.", true); BindGrid(); } else { Config.MsgBoxAjax(Config._DefaultErrorMessages); ShowPopup(); } } catch (Exception er) { DALC.ErrorLogsInsert("IndividualComplaints catch error: " + er.Message); Config.MsgBoxAjax(Config._DefaultErrorMessages); ShowPopup(); } }
public static DALC.DataTableResult GetAdoptionSearchHistory(Dictionary <string, object> Dictionary, int PageNumber, int RowNumber = 20) { DALC.DataTableResult AdoptionSearchHistory = new DALC.DataTableResult(); SqlCommand com = new SqlCommand(); string Key = ""; object Value = ""; string[] Query = { "IS NULL", "IS NOT NULL" }; StringBuilder AddWhere = new StringBuilder("Where 1=1"); StringBuilder ORWhere = new StringBuilder(); if (Dictionary != null) { int i = 0; foreach (var Item in Dictionary) { Key = Item.Key.ToUpper().Replace("İ", "I"); Value = Item.Value; i++; if (!string.IsNullOrEmpty(Convert.ToString(Value)) && Convert.ToString(Value) != "-1") { // --Eger tarix araligi lazim olarsa-- if (Key.Contains("(BETWEEN)")) { AddWhere.AppendFormat(" and ({0} Between @PDt1{1} and @PDt2{1})", Key.Replace("(BETWEEN)", ""), i.ToString()); com.Parameters.Add("@PDt1" + i.ToString(), SqlDbType.NVarChar).Value = Value._ToString().Split('&')[0]; com.Parameters.Add("@PDt2" + i.ToString(), SqlDbType.NVarChar).Value = Value._ToString().Split('&')[1]; } else if (Key.Contains("(LIKE)")) { AddWhere.AppendFormat(" and {0} Like '%' + @P{1} + '%'", Key.Replace("(LIKE)", ""), i.ToString()); com.Parameters.AddWithValue("@P" + i.ToString(), Value.LikeFormat()); } else if (Key.ToUpper().Contains("(IN)")) { AddWhere.AppendFormat(" and {0} in(Select item from SplitString(@wIn{1},','))", Key.Replace("(IN)", ""), i.ToString()); com.Parameters.AddWithValue("@wIn" + i.ToString(), Value); } else if (Key.ToUpper().Contains("(NOTIN)")) { AddWhere.AppendFormat(" and {0} not in(Select item from SplitString(@wNotIn{1},','))", Key.Replace("(NOTIN)", ""), i.ToString()); com.Parameters.AddWithValue("@wNotIn" + i.ToString(), Value); } else if (Array.IndexOf(Query, Value._ToString().ToUpper()) > -1) { AddWhere.AppendFormat(" and {0} {1}", Key, Value); } else { AddWhere.AppendFormat(" and {0}=@P{1}", Key, i.ToString()); com.Parameters.AddWithValue("@P" + i.ToString(), Value); } } } if (ORWhere.Length > 0) { AddWhere.AppendFormat(" and ({0})", ORWhere.Remove(ORWhere.ToString().Length - 2, 2)); } } string QueryCommand = @"Select {0} From (Select Row_Number() Over (Order By ASH.ID desc) as RowIndex, ASH.*,AO.Name as AdoptionOrganizations From AdoptionSearchHistory as ASH LEFT JOIN AdoptionOrganizations as AO on AO.ID=ASH.AdoptionOrganizationsID {1} ) as ASH {2}"; com.Connection = DALC.SqlConn; com.CommandText = string.Format(QueryCommand, "COUNT(ASH.ID)", AddWhere, ""); try { com.Connection.Open(); AdoptionSearchHistory.Count = com.ExecuteScalar()._ToInt32(); } catch (Exception er) { DALC.ErrorLogsInsert(string.Format("DALC_Adoption.GetAdoptionSearchHistory TableName: {0} count xəta: {1}", "AdoptionSearchHistory", er.Message)); AdoptionSearchHistory.Count = -1; AdoptionSearchHistory.Dt = null; return(AdoptionSearchHistory); } finally { com.Connection.Close(); } string RowIndexWhere = " Where ASH.RowIndex BETWEEN @R1 AND @R2"; com.Parameters.Add("@R1", SqlDbType.Int).Value = ((PageNumber * RowNumber) - RowNumber) + 1; com.Parameters.Add("@R2", SqlDbType.Int).Value = PageNumber * RowNumber; com.CommandText = string.Format(QueryCommand, "ASH.* ", AddWhere, RowIndexWhere); try { new SqlDataAdapter(com).Fill(AdoptionSearchHistory.Dt); return(AdoptionSearchHistory); } catch (Exception er) { DALC.ErrorLogsInsert(string.Format("DALC_Adoption.GetAdoptionSearchHistory TableName: {0} xəta: {1}", "AdoptionSearchHistory", er.Message)); AdoptionSearchHistory.Count = -1; AdoptionSearchHistory.Dt = null; return(AdoptionSearchHistory); } }
public static DALC.DataTableResult GetAdoptionAdministratorHistory(int Top, Dictionary <string, object> Dictionary, string OrderBy = "") { DALC.DataTableResult AdoptionAdministratorHistory = new DALC.DataTableResult(); SqlCommand com = new SqlCommand(); string Key = ""; object Value = ""; string[] Query = { "IS NULL", "IS NOT NULL" }; StringBuilder AddWhere = new StringBuilder("Where 1=1"); StringBuilder ORWhere = new StringBuilder(); if (Dictionary != null) { int i = 0; foreach (var Item in Dictionary) { Key = Item.Key.ToUpper().Replace("İ", "I"); Value = Item.Value; i++; if (!string.IsNullOrEmpty(Convert.ToString(Value)) && Convert.ToString(Value) != "-1") { // --Eger tarix araligi lazim olarsa-- if (Key.Contains("(BETWEEN)")) { AddWhere.AppendFormat(" and ({0} Between @PDt1{1} and @PDt2{1})", Key.Replace("(BETWEEN)", ""), i.ToString()); com.Parameters.Add("@PDt1" + i.ToString(), SqlDbType.NVarChar).Value = Value._ToString().Split('&')[0]; com.Parameters.Add("@PDt2" + i.ToString(), SqlDbType.NVarChar).Value = Value._ToString().Split('&')[1] + " 23:59:59"; } else if (Key.Contains("(LIKE)")) { AddWhere.AppendFormat(" and {0} Like '%' + @P{1} + '%'", Key.Replace("(LIKE)", ""), i.ToString()); com.Parameters.AddWithValue("@P" + i.ToString(), Value); } else if (Key.ToUpper().Contains("(IN)")) { AddWhere.AppendFormat(" and {0} in(Select item from SplitString(@wIn{0},','))", Key.Replace("(IN)", "")); com.Parameters.AddWithValue("@wIn" + Key.Replace("(IN)", ""), Value); } else if (Array.IndexOf(Query, Value._ToString().ToUpper()) > -1) { AddWhere.AppendFormat(" and {0} {1}", Key, Value); } else { AddWhere.AppendFormat(" and {0}=@P{1}", Key, i.ToString()); com.Parameters.AddWithValue("@P" + i.ToString(), Value); } } } if (ORWhere.Length > 0) { AddWhere.AppendFormat(" and ({0})", ORWhere.Remove(ORWhere.ToString().Length - 2, 2)); } } string QueryCommand = @"Select {0} From AdoptionAdministratorsHistory as AAH LEFT JOIN AdoptionAdministrators as AA on AAH.AdoptionAdministratorsID=AA.ID {1} {2}"; com.Connection = DALC.SqlConn; com.CommandText = string.Format(QueryCommand, "COUNT(AAH.ID)", AddWhere, OrderBy); try { com.Connection.Open(); AdoptionAdministratorHistory.Count = com.ExecuteScalar()._ToInt32(); } catch (Exception er) { DALC.ErrorLogsInsert("AdoptionAdministratorHistory count xəta: " + er.Message); AdoptionAdministratorHistory.Count = -1; AdoptionAdministratorHistory.Dt = null; return(AdoptionAdministratorHistory); } finally { com.Connection.Close(); } com.CommandText = String.Format(QueryCommand, @"Top (@Top) AAH.ID, AAH.AdoptionAdministratorsID, AA.Username as UserName, AA.Fullname as FullName, AAH.LogText as Logtext, FORMAT(AAH.Add_Dt, 'dd.MM.yyyy hh:mm') as Date, AAH.Add_Ip as Ip", AddWhere, OrderBy); com.Parameters.Add("@Top", SqlDbType.Int).Value = Top; try { new SqlDataAdapter(com).Fill(AdoptionAdministratorHistory.Dt); return(AdoptionAdministratorHistory); } catch (Exception er) { DALC.ErrorLogsInsert("AdoptionAdministratorHistory xəta: " + er.Message); AdoptionAdministratorHistory.Count = -1; AdoptionAdministratorHistory.Dt = null; return(AdoptionAdministratorHistory); } }
public static DALC.DataTableResult GetAdoptionPersons(Dictionary <string, object> Dictionary, int PageNumber, int RowNumber = 20) { DALC.DataTableResult AdoptionPersonsList = new DALC.DataTableResult(); SqlCommand com = new SqlCommand(); string Key = ""; object Value = ""; string[] Query = { "IS NULL", "IS NOT NULL" }; StringBuilder AddWhere = new StringBuilder("Where 1=1"); StringBuilder ORWhere = new StringBuilder(); if (Dictionary != null) { int i = 0; foreach (var Item in Dictionary) { Key = Item.Key.ToUpper().Replace("İ", "I"); Value = Item.Value; i++; if (!string.IsNullOrEmpty(Convert.ToString(Value)) && Convert.ToString(Value) != "-1") { // --Eger tarix araligi lazim olarsa-- if (Key.Contains("(BETWEEN)")) { AddWhere.AppendFormat(" and ({0} Between @PDt1{1} and @PDt2{1})", Key.Replace("(BETWEEN)", ""), i.ToString()); com.Parameters.Add("@PDt1" + i.ToString(), SqlDbType.NVarChar).Value = Value._ToString().Split('&')[0]; com.Parameters.Add("@PDt2" + i.ToString(), SqlDbType.NVarChar).Value = Value._ToString().Split('&')[1]; } else if (Key.Contains("(LIKE)")) { AddWhere.AppendFormat(" and {0} Like '%' + @P{1} + '%'", Key.Replace("(LIKE)", ""), i.ToString()); com.Parameters.AddWithValue("@P" + i.ToString(), Value.LikeFormat()); } else if (Key.ToUpper().Contains("(IN)")) { AddWhere.AppendFormat(" and {0} in(Select item from SplitString(@wIn{1},','))", Key.Replace("(IN)", ""), i.ToString()); com.Parameters.AddWithValue("@wIn" + i.ToString(), Value); } else if (Key.ToUpper().Contains("(NOTIN)")) { AddWhere.AppendFormat(" and {0} not in(Select item from SplitString(@wNotIn{1},','))", Key.Replace("(NOTIN)", ""), i.ToString()); com.Parameters.AddWithValue("@wNotIn" + i.ToString(), Value); } else if (Array.IndexOf(Query, Value._ToString().ToUpper()) > -1) { AddWhere.AppendFormat(" and {0} {1}", Key, Value); } else { AddWhere.AppendFormat(" and {0}=@P{1}", Key, i.ToString()); com.Parameters.AddWithValue("@P" + i.ToString(), Value); } } } if (ORWhere.Length > 0) { AddWhere.AppendFormat(" and ({0})", ORWhere.Remove(ORWhere.ToString().Length - 2, 2)); } } string QueryCommand = @"Select {0} From (Select Row_Number() Over (Order By Ap.ID desc) as RowIndex, CONCAT(Soyad,' ',Ad,' ',Ata) as Fullname , CONCAT(r.Name,' , ',c.Name) as Location , ec.Name as EyeColor, hc.Name as HairColor, AO.Name as AdoptionOrganizations, CONVERT(int,ROUND(DATEDIFF(hour,DogumTarixi,GETDATE())/8766.0,0)) as Yash, Ap.* From AdoptionPersons as Ap LEFT JOIN Colors as ec on ec.ID=Ap.GozColorsID LEFT JOIN Colors as hc on hc.ID=Ap.SachColorsID LEFT JOIN Countries as c on c.ID=Ap.CountriesID LEFT JOIN Regions as r on r.ID=Ap.RegionsID LEFT JOIN AdoptionOrganizations as AO on AO.ID=AP.AdoptionOrganizationsID {1} ) as Ap {2}"; com.Connection = DALC.SqlConn; com.CommandText = string.Format(QueryCommand, "COUNT(Ap.ID)", AddWhere, ""); try { com.Connection.Open(); AdoptionPersonsList.Count = com.ExecuteScalar()._ToInt32(); } catch (Exception er) { DALC.ErrorLogsInsert(string.Format("DALC_Adoption.GetAdoptionPersons TableName: {0} count xəta: {1}", "AdoptionPersons", er.Message)); AdoptionPersonsList.Count = -1; AdoptionPersonsList.Dt = null; return(AdoptionPersonsList); } finally { com.Connection.Close(); } string RowIndexWhere = " Where Ap.RowIndex BETWEEN @R1 AND @R2"; com.Parameters.Add("@R1", SqlDbType.Int).Value = ((PageNumber * RowNumber) - RowNumber) + 1; com.Parameters.Add("@R2", SqlDbType.Int).Value = PageNumber * RowNumber; com.CommandText = string.Format(QueryCommand, "Ap.* ", AddWhere, RowIndexWhere); try { new SqlDataAdapter(com).Fill(AdoptionPersonsList.Dt); return(AdoptionPersonsList); } catch (Exception er) { DALC.ErrorLogsInsert(string.Format("DALC_Adoption.GetAdoptionPersons TableName: {0} xəta: {1}", "AdoptionPersons", er.Message)); AdoptionPersonsList.Count = -1; AdoptionPersonsList.Dt = null; return(AdoptionPersonsList); } }