private void ClientLoad(string clientID) { Models.DataBaseContext dataBaseContext = null; try { dataBaseContext = new Models.DataBaseContext(); Models.PermanentClient permanentClient = dataBaseContext.PermanentClients .Where(current => string.Compare(current.Client_ID, clientID) == 0) .FirstOrDefault(); if (permanentClient != null) { ClientID_FirstLoad = permanentClient.Client_ID; FullName_FirstLoad = permanentClient.Full_Name; } if (ClientID_FirstLoad.StartsWith("09")) { clientIDTextBox.Text = ClientID_FirstLoad.Insert(4, "-"); } fullNameTextBox.Text = FullName_FirstLoad; } catch (System.Exception ex) { Infrastructure.Utility.ExceptionShow(ex); } finally { if (dataBaseContext != null) { dataBaseContext.Dispose(); dataBaseContext = null; } } }
private void ClientIDTextBox_Leave(object sender, System.EventArgs e) { if (string.IsNullOrWhiteSpace(clientIDTextBox.Text) || string.Compare(clientIDTextBox.Text, ClientID_FirstLoad) == 0) { confirmClientIDPicturBox.Visible = false; clientIDTextBox.ForeColor = Infrastructure.Utility.DarkGrayColor(); clientIDPanel.BackColor = Infrastructure.Utility.DarkGrayColor(); clientIDTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; clientIDTextBox.Text = ClientID_FirstLoad.Insert(4, "-"); ClientID_New = string.Empty; } else { ClientID_New = clientIDTextBox.Text; if (ClientID.Length < 11) { confirmClientIDPicturBox.Visible = true; confirmClientIDPicturBox.Image = Properties.Resources.Tik_False; clientIDTextBox.Focus(); ClientID_New = null; return; } else { if (Validation_ClientID(clientIDTextBox.Text) == true) { clientIDTextBox.ForeColor = Infrastructure.Utility.WhiteColor(); clientIDPanel.BackColor = Infrastructure.Utility.WhiteColor(); clientIDTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; if (clientIDTextBox.Text.StartsWith("09")) { showMessageToolTip.ToolTipTitle = "فرمت کد باید با 09 آغاز گردد."; confirmClientIDPicturBox.Visible = true; confirmClientIDPicturBox.Image = Properties.Resources.Tik_True; editClientButton.Enabled = true; clientIDTextBox.Text = clientIDTextBox.Text.Insert(4, "-"); ClientID_New = ClientID_New.Replace("-", string.Empty).Trim(); } else { clientIDTextBox.Focus(); return; } } else if (Validation_ClientID(clientIDTextBox.Text) == false) { confirmClientIDPicturBox.Visible = true; confirmClientIDPicturBox.Image = Properties.Resources.Tik_False; clientIDTextBox.Focus(); ClientID_New = null; editClientButton.Enabled = false; } } } }