public override string ToString() { string json = string.Concat( __jsonIgnore.ContainsKey("Id") ? string.Empty : string.Format(", Id : {0}", Id == null ? "null" : Id.ToString()), __jsonIgnore.ContainsKey("Member_id") ? string.Empty : string.Format(", Member_id : {0}", Member_id == null ? "null" : Member_id.ToString()), __jsonIgnore.ContainsKey("Address") ? string.Empty : string.Format(", Address : {0}", Address == null ? "null" : string.Format("'{0}'", Address.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Create_time") ? string.Empty : string.Format(", Create_time : {0}", Create_time == null ? "null" : Create_time.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()), __jsonIgnore.ContainsKey("Is_default") ? string.Empty : string.Format(", Is_default : {0}", Is_default == null ? "null" : (Is_default == true ? "true" : "false")), __jsonIgnore.ContainsKey("Name") ? string.Empty : string.Format(", Name : {0}", Name == null ? "null" : string.Format("'{0}'", Name.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Tel") ? string.Empty : string.Format(", Tel : {0}", Tel == null ? "null" : string.Format("'{0}'", Tel.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Telphone") ? string.Empty : string.Format(", Telphone : {0}", Telphone == null ? "null" : string.Format("'{0}'", Telphone.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Zip") ? string.Empty : string.Format(", Zip : {0}", Zip == null ? "null" : string.Format("'{0}'", Zip.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), " }"); return(string.Concat("{", json.Substring(1))); }
public override Lfx.Types.OperationResult ValidarControl() { if (EntradaTipo.ValueInt <= 0) { return(new Lfx.Types.FailureOperationResult("Seleccione el tipo de cliente")); } Lbl.Personas.Persona Cliente = this.Elemento as Lbl.Personas.Persona; if (EntradaNombreFantasia.Text.Length > 0 && EntradaRazonSocial.Text.Length == 0) { return(new Lfx.Types.FailureOperationResult("Escriba la razón social")); } if (EntradaRazonSocial.Text.Length == 0 && EntradaNombre.Text.Length == 0 && EntradaApellido.Text.Length == 0) { return(new Lfx.Types.FailureOperationResult("Escriba el nombre y el apellido o la razón social")); } else { //Busco un cliente con datos similares Lfx.Data.Row ClienteDup = null; string Sql = @"SELECT id_persona, nombre_visible, domicilio, telefono, cuit, email FROM personas WHERE ("; if (this.Text.Length > 0) { Sql += @"nombre_visible LIKE '%" + this.Connection.EscapeString(this.Text.Replace("%", "").Replace("_", "")) + @"%'"; } if (EntradaDomicilio.Text.Length > 0) { Sql += @" OR domicilio LIKE '%" + Lfx.Workspace.Master.MasterConnection.EscapeString(EntradaDomicilio.Text) + @"%'"; } if (EntradaNumDoc.Text.Length > 0) { Sql += @" OR REPLACE(num_doc, '.', '') LIKE '%" + Lfx.Workspace.Master.MasterConnection.EscapeString(EntradaNumDoc.Text.Replace(".", "")) + @"%'"; } if (EntradaTelefono.Text.Length > 0) { string Telefono = EntradaTelefono.Text.Replace(" -", "").Replace("- ", "").Replace("/", " ").Replace(",", " ").Replace(".", " ").Replace(" ", " ").Replace("%", "").Replace("_", ""); IList <string> Telefonos = Lfx.Types.Strings.SplitDelimitedString(Telefono, ";"); if (Telefonos != null && Telefonos.Count > 0) { foreach (string Tel in Telefonos) { if (Tel != null && Tel.Length > 4) { Sql += @" OR telefono LIKE '%" + Lfx.Workspace.Master.MasterConnection.EscapeString(Tel.Replace("%", "").Replace("_", "")) + @"%'"; } } } } if (EntradaEmail.Text.Length > 0) { Sql += @" OR email LIKE '%" + Lfx.Workspace.Master.MasterConnection.EscapeString(EntradaEmail.Text.Replace("%", "").Replace("_", "")) + @"%'"; } if (EntradaClaveTributaria.Text.Length > 0) { Sql += @" OR cuit='" + Lfx.Workspace.Master.MasterConnection.EscapeString(EntradaClaveTributaria.Text.Replace("%", "").Replace("_", "")) + @"'"; } Sql += @") AND id_persona<>" + this.Elemento.Id.ToString(); ClienteDup = this.Connection.FirstRowFromSelect(Sql); if (ClienteDup != null) { if (Cliente != null && Cliente.Existe == false) { AltaDuplicada FormAltaDuplicada = new AltaDuplicada(); ListViewItem itm; itm = FormAltaDuplicada.ListaComparacion.Items.Add("Nombre"); itm.SubItems.Add(ClienteDup["nombre_visible"].ToString()); itm.SubItems.Add(this.Text); itm = FormAltaDuplicada.ListaComparacion.Items.Add("Domicilio"); itm.SubItems.Add(ClienteDup["domicilio"].ToString()); itm.SubItems.Add(EntradaDomicilio.Text); itm = FormAltaDuplicada.ListaComparacion.Items.Add("Teléfono"); itm.SubItems.Add(ClienteDup["telefono"].ToString()); itm.SubItems.Add(EntradaTelefono.Text); itm = FormAltaDuplicada.ListaComparacion.Items.Add(Lbl.Sys.Config.Pais.ClavePersonasJuridicas.Nombre); if (ClienteDup["cuit"] != null) { itm.SubItems.Add(ClienteDup["cuit"].ToString()); } else { itm.SubItems.Add(""); } itm.SubItems.Add(EntradaClaveTributaria.Text); itm = FormAltaDuplicada.ListaComparacion.Items.Add("E-mail"); if (ClienteDup["email"] != null) { itm.SubItems.Add(ClienteDup["email"].ToString()); } else { itm.SubItems.Add(""); } itm.SubItems.Add(EntradaEmail.Text); switch (FormAltaDuplicada.ShowDialog()) { case DialogResult.Yes: //Crear uno nuevo return(new Lfx.Types.SuccessOperationResult()); case DialogResult.No: //Actualizar this.Elemento = new Lbl.Personas.Persona(this.Elemento.Connection, System.Convert.ToInt32(ClienteDup["id_persona"])); return(new Lfx.Types.SuccessOperationResult()); case DialogResult.Cancel: //Volver a la edición return(new Lfx.Types.CancelOperationResult()); } } } } switch (Lbl.Sys.Config.Pais.ClaveBancaria.Nombre) { case "CBU": if (EntradaClaveBancaria.Text.Length > 0 && Lbl.Bancos.Claves.Cbu.EsValido(EntradaClaveBancaria.Text) == false) { return(new Lfx.Types.FailureOperationResult("La CBU es incorrecta.")); } break; } if (Cliente.Existe == false && Cliente.Grupo != null && Cliente.Grupo.Id == 2 && (EntradaClaveBancaria.Text.Length > 0 || EntradaNumeroCuenta.Text.Length > 0) && EntradaTipoCuenta.TextKey == "0") { return(new Lfx.Types.FailureOperationResult("Por favor seleccione el tipo de cuenta bancaria.")); } if (Lbl.Sys.Config.Pais.ClavePersonasJuridicas != null) { switch (Lbl.Sys.Config.Pais.ClavePersonasJuridicas.Nombre) { case "CUIT": if (EntradaClaveTributaria.Text.Length > 0) { if (EntradaSituacion.ValueInt == 1) { return(new Lfx.Types.FailureOperationResult(@"Un Cliente con CUIT no debe estar en Situación de ""Consumidor Final"".")); } if (System.Text.RegularExpressions.Regex.IsMatch(EntradaClaveTributaria.Text, @"^\d{11}$")) { EntradaClaveTributaria.Text = EntradaClaveTributaria.Text.Substring(0, 2) + "-" + EntradaClaveTributaria.Text.Substring(2, 8) + "-" + EntradaClaveTributaria.Text.Substring(10, 1); } //Agrego los guiones si no los tiene if (EntradaClaveTributaria.Text.Length == 11) { EntradaClaveTributaria.Text = EntradaClaveTributaria.Text.Substring(0, 2) + "-" + EntradaClaveTributaria.Text.Substring(2, 8) + "-" + EntradaClaveTributaria.Text.Substring(10, 1); } if (Lbl.Personas.Claves.Cuit.EsValido(EntradaClaveTributaria.Text) == false) { return(new Lfx.Types.FailureOperationResult("La CUIT no es correcta." + Environment.NewLine + "El sistema le permite dejar la CUIT en blanco, pero no aceptará una incorrecta.")); } } break; } } if (EntradaClaveTributaria.Text.Length > 0) { Lfx.Data.Row RowPersMismaClave = this.Connection.FirstRowFromSelect("SELECT id_persona FROM personas WHERE cuit='" + EntradaClaveTributaria.Text + "' AND id_persona<>" + this.Elemento.Id.ToString()); if (RowPersMismaClave != null) { if (Cliente.Existe == false || System.Convert.ToInt32(RowPersMismaClave["id_persona"]) != this.Elemento.Id) { Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("Ya existe una empresa o persona con esa clave tributaria (" + Lbl.Sys.Config.Pais.ClavePersonasJuridicas.Nombre + ") en la base de datos. ¿Desea continuar y crear una nueva de todos modos?", "Clave tributaria duplicada"); Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo; if (Pregunta.ShowDialog() != DialogResult.OK) { return(new Lfx.Types.FailureOperationResult("Cambie la Clave tributaria (" + Lbl.Sys.Config.Pais.ClavePersonasJuridicas.Nombre + ") para antes de continuar.")); } } } } return(new Lfx.Types.SuccessOperationResult()); }
public override string ToString() { this.Init__jsonIgnore(); string json = string.Concat( __jsonIgnore.ContainsKey("Id") ? string.Empty : string.Format(", Id : {0}", Id == null ? "null" : Id.ToString()), __jsonIgnore.ContainsKey("Activeid") ? string.Empty : string.Format(", Activeid : {0}", Activeid == null ? "null" : string.Format("'{0}'", Activeid.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Gate") ? string.Empty : string.Format(", Gate : {0}", Gate == null ? "null" : string.Format("'{0}'", Gate.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Rewarditem") ? string.Empty : string.Format(", Rewarditem : {0}", Rewarditem == null ? "null" : Rewarditem.ToString()), __jsonIgnore.ContainsKey("State") ? string.Empty : string.Format(", State : {0}", State == null ? "null" : State.ToString()), __jsonIgnore.ContainsKey("Tel") ? string.Empty : string.Format(", Tel : {0}", Tel == null ? "null" : string.Format("'{0}'", Tel.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Time") ? string.Empty : string.Format(", Time : {0}", Time == null ? "null" : Time.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()), " }"); return(string.Concat("{", json.Substring(1))); }
public override string ToString() { string json = string.Concat( __jsonIgnore.ContainsKey("Id") ? string.Empty : string.Format(", Id : {0}", Id == null ? "null" : Id.ToString()), __jsonIgnore.ContainsKey("Order_id") ? string.Empty : string.Format(", Order_id : {0}", Order_id == null ? "null" : Order_id.ToString()), __jsonIgnore.ContainsKey("Productitem_id") ? string.Empty : string.Format(", Productitem_id : {0}", Productitem_id == null ? "null" : Productitem_id.ToString()), __jsonIgnore.ContainsKey("Create_time") ? string.Empty : string.Format(", Create_time : {0}", Create_time == null ? "null" : Create_time.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()), __jsonIgnore.ContainsKey("Descript") ? string.Empty : string.Format(", Descript : {0}", Descript == null ? "null" : string.Format("'{0}'", Descript.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Email") ? string.Empty : string.Format(", Email : {0}", Email == null ? "null" : string.Format("'{0}'", Email.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Img_url") ? string.Empty : string.Format(", Img_url : {0}", Img_url == null ? "null" : string.Format("'{0}'", Img_url.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("State") ? string.Empty : string.Format(", State : {0}", State == null ? "null" : string.Format("'{0}'", State.ToDescriptionOrString().Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Tel") ? string.Empty : string.Format(", Tel : {0}", Tel == null ? "null" : string.Format("'{0}'", Tel.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Telphone") ? string.Empty : string.Format(", Telphone : {0}", Telphone == null ? "null" : string.Format("'{0}'", Telphone.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Wealth") ? string.Empty : string.Format(", Wealth : {0}", Wealth == null ? "null" : Wealth.ToString()), " }"); return(string.Concat("{", json.Substring(1))); }
public override string ToString() { string json = string.Concat( __jsonIgnore.ContainsKey("Order_id") ? string.Empty : string.Format(", Order_id : {0}", Order_id == null ? "null" : Order_id.ToString()), __jsonIgnore.ContainsKey("Address") ? string.Empty : string.Format(", Address : {0}", Address == null ? "null" : string.Format("'{0}'", Address.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Name") ? string.Empty : string.Format(", Name : {0}", Name == null ? "null" : string.Format("'{0}'", Name.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Tel") ? string.Empty : string.Format(", Tel : {0}", Tel == null ? "null" : string.Format("'{0}'", Tel.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Telphone") ? string.Empty : string.Format(", Telphone : {0}", Telphone == null ? "null" : string.Format("'{0}'", Telphone.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Zip") ? string.Empty : string.Format(", Zip : {0}", Zip == null ? "null" : string.Format("'{0}'", Zip.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), " }"); return(string.Concat("{", json.Substring(1))); }
private void SaveButton_Click(object sender, System.EventArgs e) { Models.DataBaseContext dataBaseContext = null; try { dataBaseContext = new Models.DataBaseContext(); string inputError = string.Empty; #region Validation if (string.IsNullOrEmpty(Username)) { inputError = "مشخصه شناسه کاربری را تکمیل کنید!"; } if (string.IsNullOrEmpty(Email)) { if (string.IsNullOrEmpty(inputError) == false) { inputError += System.Environment.NewLine; } inputError += "مشخصه پست الکترونیکی را تکمیل کنید!"; } if (string.IsNullOrEmpty(Password)) { if (string.IsNullOrEmpty(inputError) == false) { inputError += System.Environment.NewLine; } inputError += "مشخصه رمز عبور را تکمیل کنید!"; } if (string.IsNullOrEmpty(PasswordConfirm)) { if (string.IsNullOrEmpty(inputError) == false) { inputError += System.Environment.NewLine; } inputError += "مشخصه تایید رمز عبور را تکمیل کنید!"; } if (string.IsNullOrEmpty(UserImage)) { if (string.IsNullOrEmpty(inputError) == false) { inputError += System.Environment.NewLine; } inputError += "مشخصه تصویر کاربری را تکمیل کنید!"; } if (string.IsNullOrEmpty(FirstName)) { if (string.IsNullOrEmpty(inputError) == false) { inputError += System.Environment.NewLine; } inputError += "مشخصه نام را تکمیل کنید!"; } if (string.IsNullOrEmpty(LastName)) { if (string.IsNullOrEmpty(inputError) == false) { inputError += System.Environment.NewLine; } inputError += "مشخصه نام خانوادگی را تکمیل کنید!"; } if (string.IsNullOrEmpty(Tel)) { if (string.IsNullOrEmpty(inputError) == false) { inputError += System.Environment.NewLine; } inputError += "مشخصه شماره تماس را تکمیل کنید!"; } //------------------------------------------------ if (string.IsNullOrEmpty(inputError) != true) { if (string.IsNullOrEmpty(Username)) { usernameTextBox.Focus(); } else if (string.IsNullOrEmpty(Email)) { emailTextBox.Focus(); } else if (string.IsNullOrEmpty(Password)) { passwordTextBox.Focus(); } else if (string.IsNullOrEmpty(PasswordConfirm)) { passwordConfirmTextBox.Focus(); } else if (string.IsNullOrEmpty(UserImage)) { System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog { Filter = "JPG (*.jpg)|*.jpg|" + "PNG (*.png)|*.png|" + "BMP (*.bmp)|*.bmp", Title = "Load user picture ", }; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { UserImage = openFileDialog.FileName; userImagePicturBox.BackgroundImage = System.Drawing.Image.FromFile(UserImage); } if (UserImage != string.Empty) { deleteImageButton.Visible = true; } else { deleteImageButton.Visible = false; } } else if (string.IsNullOrEmpty(FirstName)) { firstNameTextBox.Focus(); } else if (string.IsNullOrEmpty(LastName)) { lastNameTextBox.Focus(); } else if (string.IsNullOrEmpty(Tel)) { telTextBox.Focus(); } Mbb.Windows.Forms.MessageBox.Show (text: inputError, caption: "خطای ورودی", icon: Mbb.Windows.Forms.MessageBoxIcon.Error, button: Mbb.Windows.Forms.MessageBoxButtons.Ok); return; } if (Infrastructure.Utility.PasswordSet(password: Password, passwordConfirm: PasswordConfirm) == false) { Mbb.Windows.Forms.MessageBox.Show (text: "عدم تطابق پسوردها", caption: "خطای ورودی", icon: Mbb.Windows.Forms.MessageBoxIcon.Error, button: Mbb.Windows.Forms.MessageBoxButtons.Ok); passwordTextBox.Focus(); return; } #endregion /Validation System.Windows.Forms.DialogResult dialogResult; string message = $"نام کاربری {Username} ذخیره گردد؟."; dialogResult = Mbb.Windows.Forms.MessageBox.Show (text: message, caption: "ذخیره اطلاعات", icon: Mbb.Windows.Forms.MessageBoxIcon.Question, button: Mbb.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { Models.User username = dataBaseContext.Users .Where(current => string.Compare(current.Username, Username) == 0) .FirstOrDefault(); if (username != null) { Mbb.Windows.Forms.MessageBox.Show (text: $"نام کاربری {Username} در سیستم موجود میباشد. لطفا از نام دیگری استفاده نمایید.", caption: "اطلاعات مشابه", icon: Mbb.Windows.Forms.MessageBoxIcon.Information, button: Mbb.Windows.Forms.MessageBoxButtons.Ok); usernameTextBox.Focus(); return; } else { RegisterDate = Infrastructure.Utility.PersianCalendar(System.DateTime.Now); RegisterTime = Infrastructure.Utility.ShowTime(); username = new Models.User { IsActive = true, IsAdministrator = false, Username = Username, Email = Email, Password = Password, Description = Description, First_Name = FirstName, Last_Name = LastName, Telephone = Tel.Replace("-", ""), National_Code = NationalCode, Marital_Status = Marride, Address = Address, Registration_Date = RegisterDate, Registration_Time = RegisterTime, User_Image = System.IO.File.ReadAllBytes(UserImage), }; dataBaseContext.Users.Add(username); dataBaseContext.SaveChanges(); } } else { return; } string successMessage = $"اطلاعات کاربر {Username} با موفقیت ذخیره گرید!"; Infrastructure.Utility.WindowsNotification (message: successMessage, caption: Infrastructure.PopupNotificationForm.Caption.موفقیت, picture: UserImage); AllClear(); } catch (System.Exception ex) { Infrastructure.Utility.ExceptionShow(ex); } finally { if (dataBaseContext != null) { dataBaseContext.Dispose(); dataBaseContext = null; } } }