예제 #1
0
        //-----
        #endregion /SearchTextBox

        #region DeleteTableButton_Click
        private void DeleteTableButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                System.Collections.Generic.List <Models.LogHistory> logHistories = null;

                System.Windows.Forms.DialogResult dialogResult = Mbb.Windows.Forms.MessageBox.QuestionMessage(
                    text: "آیا گزارش پاک گردد؟",
                    captiopn: "پاک کردن گزارش",
                    buttons: System.Windows.Forms.MessageBoxButtons.YesNo,
                    icon: System.Windows.Forms.MessageBoxIcon.Question,
                    defaultButton: System.Windows.Forms.MessageBoxDefaultButton.Button2,
                    options: System.Windows.Forms.MessageBoxOptions.RightAlign |
                    System.Windows.Forms.MessageBoxOptions.RtlReading);

                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    var rows = from o in dataBaseContext.LogHistories select o;

                    foreach (var row in rows)
                    {
                        dataBaseContext.LogHistories.Remove(row);
                    }

                    dataBaseContext.SaveChanges();
                    LoginControlLoaded();
                    return;
                }
                else
                {
                    return;
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #2
0
        //-----End of coding line

        #region Founctions
        //-----
        #region DrinkFounded
        private void DrinkFounded(string searchDrink)
        {
            if (searchDrink.Contains("جستجو کالا ..."))
            {
                return;
            }
            else
            {
                Models.DataBaseContext dataBaseContext = null;

                try
                {
                    dataBaseContext =
                        new Models.DataBaseContext();

                    System.Collections.Generic.List <Models.Drink> drinks = null;

                    if (string.IsNullOrEmpty(searchDrink))
                    {
                        drinks =
                            dataBaseContext.Drinks
                            .OrderBy(current => current.DrinkName)
                            .ToList();
                    }
                    else
                    {
                        drinks =
                            dataBaseContext.Drinks
                            .Where(current => current.DrinkName.Contains(searchDrink))
                            .OrderBy(current => current.DrinkName)
                            .ToList();
                    }

                    drinkStoreDataGridView.DataSource = drinks;
                }
                catch (System.Exception ex)
                {
                    Infrastructure.Utility.ExceptionShow(ex);
                }
                finally
                {
                    if (dataBaseContext != null)
                    {
                        dataBaseContext.Dispose();
                        dataBaseContext = null;
                    }
                }
            }
            return;
        }
예제 #3
0
        public void LogHistoryLoaded()
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                System.Collections.Generic.List <Models.LogHistory> logHistories = null;

                logHistories =
                    dataBaseContext.LogHistories
                    .OrderByDescending(current => current.Logout_Time)
                    .ToList();

                loginControlDataGridView.DataSource = logHistories;

                if (loginControlDataGridView.Rows.Count <= 9)
                {
                    userSearchTextBox.Enabled = false;
                    printButton.Enabled       = false;
                    return;
                }
                if (loginControlDataGridView.Rows.Count >= 10 && loginControlDataGridView.Rows.Count < 15)
                {
                    userSearchTextBox.Enabled = true;
                    printButton.Enabled       = false;
                    return;
                }
                if (loginControlDataGridView.Rows.Count >= 15)
                {
                    userSearchTextBox.Enabled = true;
                    printButton.Enabled       = true;
                    return;
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #4
0
        //-----
        #endregion / Methods

        #region UpdateButton_Click
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                if (string.Compare(usernameLabel.Text, "شناسه کاربری") == 0)
                {
                    return;
                }

                Models.User user =
                    dataBaseContext.Users
                    .Where(current => string.Compare(current.Username, usernameLabel.Text) == 0)
                    .FirstOrDefault();

                if (user == null)
                {
                    Infrastructure.Utility.WindowsNotification
                        (message: "کاربر مورد نظر حذف گردیده!", caption: Infrastructure.PopupNotificationForm.Caption.اخطار);
                    return;
                }

                user.IsAdministrator = administratorCheckBox.Checked;
                user.IsActive        = activeCheckBox.Checked;

                dataBaseContext.SaveChanges();

                Infrastructure.Utility.WindowsNotification
                    (message: $" کاربر {usernameLabel.Text} به روز گردید", caption: Infrastructure.PopupNotificationForm.Caption.اطلاع);

                UserLoader();
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #5
0
        private void NewCodeButton_Click(object sender, System.EventArgs e)
        {
            this.Size = new System.Drawing.Size(490, 225);
            errorMessageLabel.Visible = false;
            int number = RandomNumbers();


            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                Models.Client client =
                    dataBaseContext.Clients
                    .Where(current => string.Compare(current.SubscriptionCode.ToString(), number.ToString()) == 0)
                    .FirstOrDefault();

                if (client != null)
                {
                    checkPicturBox.Visible = true;
                    checkPicturBox.Image   = Resturant.Properties.Resources.Tik_False;
                    return;
                }
                else
                {
                    checkPicturBox.Visible     = true;
                    checkPicturBox.Image       = Resturant.Properties.Resources.Tik_True;
                    SubscriptionCode           = number;
                    subscriptionCodeLabel.Text = SubscriptionCode.ToString();
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #6
0
        private void ClientTelTextBox_Validated(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(ClientTel))
            {
                return;
            }
            else
            {
                Models.DataBaseContext dataBaseContext = null;
                try
                {
                    dataBaseContext =
                        new Models.DataBaseContext();

                    Models.Client client =
                        dataBaseContext.Clients
                        .Where(current => string.Compare(current.ClientTel, ClientTel) == 0)
                        .FirstOrDefault();
                    if (client != null)
                    {
                        Infrastructure.Utility.WindowsNotification
                            (message: $"تلفن {ClientTel} در سیستم موجود میباشد!",
                            caption: Infrastructure.PopupNotificationForm.Caption.اخطار);

                        ClientTel = string.Empty;
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    Infrastructure.Utility.PopupNotification(ex);
                }
                finally
                {
                    if (dataBaseContext != null)
                    {
                        dataBaseContext.Dispose();
                        dataBaseContext = null;
                    }
                }
            }
        }
예제 #7
0
        //-----End of coding line

        #region Founctions
        //-----
        #region UsernameSearch
        private void UsernameSearch(string text)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                System.Collections.Generic.List <Models.LogHistory> logHistories = null;

                if (string.IsNullOrWhiteSpace(text))
                {
                    logHistories =
                        dataBaseContext.LogHistories
                        .OrderByDescending(current => current.Logout_Time)
                        .ToList();
                }
                else
                {
                    logHistories =
                        dataBaseContext.LogHistories
                        .Where(current => current.Username.Contains(text))
                        .OrderByDescending(current => current.Logout_Time)
                        .ToList();
                }

                loginControlDataGridView.DataSource = logHistories;
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
            return;
        }
예제 #8
0
        private void LogoutSearch(string logout)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                System.Collections.Generic.List <Models.LogHistory> logHistories = null;

                if (string.IsNullOrEmpty(logout))
                {
                    logHistories =
                        dataBaseContext.LogHistories
                        .OrderBy(current => current.LogoutTime)
                        .ToList();
                }

                else
                {
                    logHistories =
                        dataBaseContext.LogHistories
                        .Where(current => current.Username.Contains(logout))
                        .OrderBy(current => current.LogoutTime)
                        .ToList();
                }

                loginDataGridView.DataSource = logHistories;
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
        public void HookahLoader()
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                System.Collections.Generic.List <Models.Hookah> hookahs = null;

                hookahs =
                    dataBaseContext.Hookahs
                    .OrderBy(current => current.HookahName)
                    .ToList();

                hookahStoreDataGridView.DataSource = hookahs;

                if (hookahStoreDataGridView.Rows.Count > 0)
                {
                    deleteRecordButton.Enabled = true;
                    allClearButton.Enabled     = true;
                }
                else
                {
                    deleteRecordButton.Enabled = false;
                    allClearButton.Enabled     = false;
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
        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;
                }
            }
        }
예제 #11
0
        private void SaveLogOutTime(Models.LogHistory log)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                Models.LogHistory logHistory =
                    dataBaseContext.LogHistories
                    .Where(curren => string.Compare(curren.Username, log.Username) == 0)
                    .OrderByDescending(current => current.LoginTime)
                    .SingleOrDefault(current => current.Id == log.Id);

                if (logHistory != null)
                {
                    LogOutTime = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now).ToString()} " +
                                 $"{Infrastructure.Utility.ShowTime().ToString()}";

                    logHistory.LogoutTime = LogOutTime;
                }

                dataBaseContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #12
0
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;

            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                if (string.Compare(AccessLevel_New, AccessLeve_FirstLoad) == 0)
                {
                    AccessLevel = AccessLeve_FirstLoad;
                }
                else
                {
                    AccessLevel = AccessLevel_New;
                }

                if (Activation_New == Activation_FirstLoad)
                {
                    IsActive = Activation_FirstLoad;
                }
                else
                {
                    IsActive = Activation_New;
                }

                Models.User user =
                    dataBaseContext.Users
                    .Where(current => string.Compare(current.Username, Username) == 0)
                    .FirstOrDefault();

                if (user == null)
                {
                    return;
                }
                else
                {
                    user.IsActive     = IsActive;
                    user.Access_Level = AccessLevel;
                }
                dataBaseContext.SaveChanges();

                if (string.Compare(AccessLevel_New, AccessLeve_FirstLoad) == 0 && Activation_New == Activation_FirstLoad)
                {
                    return;
                }
                else if (string.Compare(AccessLevel_New, AccessLeve_FirstLoad) != 0 && Activation_New == Activation_FirstLoad)
                {
                    #region EventLog
                    EventLog_Username   = Program.AuthenticatedUser.Username;
                    EventLog_FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                    EventLog_EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                    EventLog_EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                    EventLog_EventTitle = $"سطح دسترسی کاربر {Username} از {AccessLeve_FirstLoad} به {AccessLevel_New} تغییر کرد";

                    Infrastructure.Utility.EventLog
                        (username: EventLog_Username,
                        fullName: EventLog_FullName,
                        eventDate: EventLog_EventDate,
                        eventTime: EventLog_EventTime,
                        eventTitle: EventLog_EventTitle);
                    #endregion /EventLog
                }
                else if (string.Compare(AccessLevel_New, AccessLeve_FirstLoad) == 0 && Activation_New != Activation_FirstLoad)
                {
                    #region EventLog
                    EventLog_Username  = Program.AuthenticatedUser.Username;
                    EventLog_FullName  = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                    EventLog_EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                    EventLog_EventTime = $"{Infrastructure.Utility.ShowTime()}";

                    if (Activation_New)
                    {
                        EventLog_EventTitle = $"کاربر {Username} فعال گردید.";
                    }
                    else
                    {
                        EventLog_EventTitle = $"کاربر {Username} غیر فعال گردید.";
                    }

                    Infrastructure.Utility.EventLog
                        (username: EventLog_Username,
                        fullName: EventLog_FullName,
                        eventDate: EventLog_EventDate,
                        eventTime: EventLog_EventTime,
                        eventTitle: EventLog_EventTitle);
                    #endregion /EventLog
                }
                else if (string.Compare(AccessLevel_New, AccessLeve_FirstLoad) != 0 && Activation_New != Activation_FirstLoad)
                {
                    #region EventLog
                    EventLog_Username  = Program.AuthenticatedUser.Username;
                    EventLog_FullName  = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                    EventLog_EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                    EventLog_EventTime = $"{Infrastructure.Utility.ShowTime()}";

                    if (Activation_New)
                    {
                        EventLog_EventTitle = $"سطح دسترسی کاربر {Username} از {AccessLeve_FirstLoad} به {AccessLevel_New} تغییر و فعال گردید.";
                    }
                    else
                    {
                        EventLog_EventTitle = $"سطح دسترسی کاربر {Username} از {AccessLeve_FirstLoad} به {AccessLevel_New} تغییر و غیر فعال گردید.";
                    }

                    Infrastructure.Utility.EventLog
                        (username: EventLog_Username,
                        fullName: EventLog_FullName,
                        eventDate: EventLog_EventDate,
                        eventTime: EventLog_EventTime,
                        eventTitle: EventLog_EventTitle);
                    #endregion /EventLog
                }

                UsersLoaded();
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
        //----------Beginning of the code!----------

        #region SaveButton_Click
        private void SaveButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                if (string.IsNullOrWhiteSpace(firstNameTextBox.Text) || string.IsNullOrWhiteSpace(lastNameTextBox.Text) || string.IsNullOrWhiteSpace(addressTextBox.Text))
                {
                    System.Windows.Forms.MessageBox.Show("لطفا فیلد های نام و نام خانوادگی و آدرس را\n تکمیل نمایید!", caption: "", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error, defaultButton:  MessageBoxDefaultButton.Button1, options: MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
                    firstNameTextBox.Focus();
                    return;
                }


                dataBaseContext =
                    new Models.DataBaseContext();

                Models.User username =
                    dataBaseContext.Users
                    .Where(current => string.Compare(current.Address, addressTextBox.Text) == 0)
                    .FirstOrDefault();

                if (username != null)
                {
                    System.Windows.Forms.MessageBox.Show("آدرس مورد نظر در سیستم موجود میباشد!\n لطفا از ادرس دیگری استفاده نمایید.");
                    addressTextBox.Clear();
                    addressTextBox.Focus();

                    return;
                }
                else
                {
                    username =
                        new Models.User
                    {
                        First_Name = firstNameTextBox.Text,
                        Last_Name  = lastNameTextBox.Text,
                        Address    = addressTextBox.Text,
                    };

                    dataBaseContext.Users.Add(username);
                    dataBaseContext.SaveChanges();

                    RefreshData();
                }
                string successMessage =
                    $"اطلاعات کاربر {lastNameTextBox.Text} با موفقیت ذخیره گرید!";

                System.Windows.Forms.MessageBox.Show(successMessage);


                ClearData();
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #14
0
        private void MyDataGridView_CellDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            if (e.ColumnIndex == -1)
            {
                return;
            }

            Models.DataBaseContext dataBaseContext = null;

            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                string selectedClient =
                    myDataGridView.CurrentRow.Cells[0].Value.ToString();

                Models.Client client =
                    dataBaseContext.Clients
                    .Where(current => string.Compare(current.SubscriptionCode.ToString(), selectedClient) == 0)
                    .FirstOrDefault();

                if (client != null)
                {
                    string message = $"آیا کد {selectedClient} حذف گردد؟";

                    System.Windows.Forms.DialogResult dialogResult =
                        Mbb.Windows.Forms.MessageBox.QuestionMessage
                            (text: message,
                            captiopn: "حذف مشترک",
                            buttons: System.Windows.Forms.MessageBoxButtons.YesNo,
                            icon: System.Windows.Forms.MessageBoxIcon.Question,
                            defaultButton: System.Windows.Forms.MessageBoxDefaultButton.Button2,
                            options: System.Windows.Forms.MessageBoxOptions.RightAlign |
                            System.Windows.Forms.MessageBoxOptions.RtlReading);

                    if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                    {
                        dataBaseContext.Clients.Remove(client);
                        dataBaseContext.SaveChanges();
                    }
                    else
                    {
                        return;
                    }
                }

                ClientLoader();

                Infrastructure.Utility.WindowsNotification
                    (message: "مشترک حذف گردید!", caption: Infrastructure.PopupNotificationForm.Caption.اطلاع);
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #15
0
        private void UpdateDataHookahButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();
                string hookaName = null;

                if (string.IsNullOrEmpty(HookahName_New))
                {
                    HookahName = HookahName_FirstLoad;
                }
                else
                {
                    HookahName = HookahName_New;
                }

                if (string.IsNullOrEmpty(HookahPrice_New))
                {
                    HookahPrice = HookahPrice_FirstLoad;
                }
                else
                {
                    HookahPrice = HookahPrice_New;
                }

                if (string.IsNullOrEmpty(HookahDescription_New))
                {
                    HookahDescription = HookahDescription_FirstLoad;
                }
                else
                {
                    HookahDescription = HookahDescription_New;
                }

                if (string.IsNullOrEmpty(Select_HookahImage))
                {
                    HookahImage = HookahImage_FirstLoad;
                }
                else
                {
                    HookahImage = HookahImage_New;
                }


                System.Windows.Forms.DialogResult dialogResult;
                dialogResult = Mbb.Windows.Forms.MessageBox.Show
                                   (text: $"{HookahName} به روز گردد؟",
                                   caption: "به روز رسانی",
                                   icon: Mbb.Windows.Forms.MessageBoxIcon.Question,
                                   button: Mbb.Windows.Forms.MessageBoxButtons.YesNo);

                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    Models.Hookah hookah =
                        dataBaseContext.Hookahs
                        .Where(current => string.Compare(current.HookahName, HookahName_FirstLoad, false) == 0)
                        .FirstOrDefault();

                    HookahNumberUpdate = hookah.NumberUpdate;
                    HookahUpdateTime   = $"{Infrastructure.Utility.ShowTime()} - {Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                    HookahNumberUpdate++;

                    hookah.HookahName        = HookahName;
                    hookah.HookahPrice       = HookahPrice;
                    hookah.HookahDescription = HookahDescription;
                    hookah.HookahImage       = HookahImage;
                    hookah.UpdateTime        = HookahUpdateTime;
                    hookah.NumberUpdate      = HookahNumberUpdate;

                    dataBaseContext.SaveChanges();

                    //-----جهت بارگذاری اطلاعات قلیان در جدول داده
                    if (HOOKAH_SALON.MainForm.HookahStoreForm != null)
                    {
                        HOOKAH_SALON.MainForm.HookahStoreForm.HookahLoader();
                    }

                    #region EventLogForFood
                    if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        return;
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و مبلغ آن از {HookahPrice_FirstLoad} به {HookahPrice_New} تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New}و توضیحات آن از {HookahDescription_FirstLoad} به {HookahDescription_New} تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و عکس آن تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و قیمت آن از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات آن از {HookahDescription_FirstLoad} به {HookahDescription_New} تغییر یافت.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و قیمت آن از {HookahPrice_FirstLoad} به {HookahPrice_New} و عکس آن تغییر یافت.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و توضیحات آن از {HookahDescription_FirstLoad} به {HookahDescription_New} و عکس آن تغییر یافت.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و قیمت از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات از {HookahDescription_FirstLoad} به {HookahDescription_FirstLoad} و عکس آن تغییر یافت.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات آن از {HookahDescription_New} به {HookahDescription_New} تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} و عکس آن تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات آن از {HookahDescription_New} به {HookahDescription_New} و عکس آن تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage))
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"توضیحات {HookahName_FirstLoad} از {HookahDescription_New} به {HookahDescription_New} تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"توضیحات {HookahName_FirstLoad} از {HookahDescription_New} به {HookahDescription_New} و عکس آن تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false)
                    {
                        #region EventLog
                        Username   = Program.AuthenticatedUser.Username;
                        FullName   = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}";
                        EventDate  = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}";
                        EventTime  = $"{Infrastructure.Utility.ShowTime()}";
                        EventTitle = $"عکس {HookahName_FirstLoad} تغییر کرد.";

                        Infrastructure.Utility.EventLog
                            (username: Username,
                            fullName: FullName,
                            eventDate: EventDate,
                            eventTime: EventTime,
                            eventTitle: EventTitle);
                        #endregion /EventLog
                    }
                    #endregion /EventLogForFood

                    string message =
                        $"{HookahName} بروز رسانی گردید.";

                    Infrastructure.Utility.WindowsNotification
                        (message: message,
                        caption: Infrastructure.PopupNotificationForm.Caption.موفقیت,
                        picture: HookahImage);
                }
                else
                {
                    return;
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #16
0
        private void SearchTextBox_TextChanged(object sender, System.EventArgs e)
        {
            #region foodSearchRadioButton
            //-----
            if (foodSearchRadioButton.Checked == true)
            {
                if (searchTextBox.Text.Contains("جستجو..."))
                {
                    return;
                }
                else
                {
                    Models.DataBaseContext dataBaseContext = null;

                    try
                    {
                        dataBaseContext =
                            new Models.DataBaseContext();

                        System.Collections.Generic.List <Models.Food> foods = null;

                        if (string.IsNullOrWhiteSpace(searchTextBox.Text))
                        {
                            foods =
                                dataBaseContext.Foods
                                .OrderBy(current => current.FoodName)
                                .ToList();
                        }
                        else
                        {
                            foods =
                                dataBaseContext.Foods
                                .Where(current => current.FoodName.Contains(searchTextBox.Text))
                                .OrderBy(current => current.FoodName)
                                .ToList();
                        }

                        foodDataGridView.DataSource = foods;
                    }
                    catch (System.Exception ex)
                    {
                        Infrastructure.Utility.PopupNotification(ex);
                    }
                    finally
                    {
                        if (dataBaseContext != null)
                        {
                            dataBaseContext.Dispose();
                            dataBaseContext = null;
                        }
                    }
                }
                return;
            }
            //-----
            #endregion /foodSearchRadioButton

            #region drinkSearchRadioButton
            //-----
            if (drinkSearchRadioButton.Checked == true)
            {
                if (searchTextBox.Text.Contains("جستجو ..."))
                {
                    return;
                }
                else
                {
                    Models.DataBaseContext dataBaseContext = null;

                    try
                    {
                        dataBaseContext =
                            new Models.DataBaseContext();

                        System.Collections.Generic.List <Models.Drink> drinks = null;

                        if (string.IsNullOrWhiteSpace(searchTextBox.Text))
                        {
                            drinks =
                                dataBaseContext.Drinks
                                .OrderBy(current => current.DrinkName)
                                .ToList();
                        }
                        else
                        {
                            drinks =
                                dataBaseContext.Drinks
                                .Where(current => current.DrinkName.Contains(searchTextBox.Text))
                                .OrderBy(current => current.DrinkName)
                                .ToList();
                        }

                        drinkDataGridView.DataSource = drinks;
                        drinkDataGridView.AutoResizeColumns
                            (autoSizeColumnsMode: System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells);
                    }
                    catch (System.Exception ex)
                    {
                        Infrastructure.Utility.PopupNotification(ex);
                    }
                    finally
                    {
                        if (dataBaseContext != null)
                        {
                            dataBaseContext.Dispose();
                            dataBaseContext = null;
                        }
                    }
                }
                return;
            }
            //-----
            #endregion /drinkSearchRadioButton

            #region dessertSearchRadioButton
            //-----
            if (dessertSearchRadioButton.Checked == true)
            {
                if (searchTextBox.Text.Contains("جستجو ..."))
                {
                    return;
                }
                else
                {
                    Models.DataBaseContext dataBaseContext = null;

                    try
                    {
                        dataBaseContext =
                            new Models.DataBaseContext();

                        System.Collections.Generic.List <Models.DessertAndAppetizer> desserts = null;

                        if (string.IsNullOrWhiteSpace(searchTextBox.Text))
                        {
                            desserts =
                                dataBaseContext.DessertAndAppetizers
                                .OrderBy(current => current.DessertName)
                                .ToList();
                        }
                        else
                        {
                            desserts =
                                dataBaseContext.DessertAndAppetizers
                                .Where(current => current.DessertName.Contains(searchTextBox.Text))
                                .OrderBy(current => current.DessertName)
                                .ToList();
                        }

                        dessertDataGridView.DataSource = desserts;
                        dessertDataGridView.AutoResizeColumns
                            (autoSizeColumnsMode: System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells);
                    }
                    catch (System.Exception ex)
                    {
                        Infrastructure.Utility.PopupNotification(ex);
                    }
                    finally
                    {
                        if (dataBaseContext != null)
                        {
                            dataBaseContext.Dispose();
                            dataBaseContext = null;
                        }
                    }
                }
                return;
            }
            //-----
            #endregion /dessertSearchRadioButton
        }
예제 #17
0
        //-----End of coding line

        #region Founctions
        //-----
        #region FormLoad
        private void FormLoad()
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                Models.Drink drink =
                    dataBaseContext.Drinks
                    .Where(current => string.Compare(current.DrinkName, DrinkName_FirstLoad, true) == 0)
                    .FirstOrDefault();

                DrinkName             = null;
                DrinkDescription_New  = null;
                drinkNameTextBox.Text = drink.DrinkName;

                DrinkPrice                  = null;
                DrinkPrice_New              = null;
                DrinkPrice_Int              = 0;
                drinkPriceTextBox.Text      = drink.DrinkPrice;
                DrinkPrice_FirstLoad        = drink.DrinkPrice;
                drinkPriceTextBox.ForeColor =
                    Infrastructure.Utility.DarkDimGary();
                drinkPricePanel.BackColor =
                    Infrastructure.Utility.DarkDimGary();


                DrinkDescription                  = null;
                DrinkDescription_New              = null;
                drinkDescriptionTextBox.Text      = drink.DrinkDescription;
                DrinkDescription_FirstLoad        = drink.DrinkDescription;
                drinkDescriptionTextBox.ForeColor =
                    Infrastructure.Utility.DarkDimGary();
                drinkDescriptionPanel.BackColor =
                    Infrastructure.Utility.DarkDimGary();

                DrinkImage           = null;
                DrinkDescription_New = null;
                DrinkImage_FirstLoad = drink.DrinkImage;
                var byteImage = drink.DrinkImage;
                if (byteImage == null)
                {
                    deleteDrinkImageButton.Visible = false;
                }
                else
                {
                    deleteDrinkImageButton.Visible = true;
                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream(byteImage))
                    {
                        drinkImagePicturBox.Image = System.Drawing.Image.FromStream(ms);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #18
0
        //-----Beginning of the codes.

        #region ClientsEditForm
        //-----
        #region ClientsEditForm_Load
        private void ClientsEditForm_Load(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                Models.Client client =
                    dataBaseContext.Clients
                    .Where(current => string.Compare(current.SubscriptionCode.ToString(), SubscriptionCode.ToString()) == 0)
                    .FirstOrDefault();

                if (client != null)
                {
                    subscriptionCodeLabel.Text = client.SubscriptionCode.ToString();
                    clientNameTextBox.Text     = client.ClientName;
                    ClientName                = client.ClientName;
                    FirstValueName            = client.ClientName;
                    clientTelTextBox.Text     = client.ClientTel;
                    ClientTel                 = client.ClientTel;
                    FirstValueTel             = client.ClientTel;
                    clientAddressTextBox.Text = client.ClientAddress;
                    ClientAddress             = client.ClientAddress;
                    FirstValueAddress         = client.ClientAddress;
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }

            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }

            if (string.Compare(subscriptionCodeLabel.Text, "کد اشتراک") != 0)
            {
                subscriptionCodeLabel.ForeColor =
                    Infrastructure.Utility.WhiteColor();
            }
            else
            {
                subscriptionCodeLabel.ForeColor =
                    Infrastructure.Utility.DimGrayColor();
            }

            if (string.Compare(clientNameTextBox.Text, "نام مشکرت") != 0)
            {
                clientNameTextBox.ForeColor =
                    Infrastructure.Utility.WhiteColor();
            }
            else
            {
                clientNameTextBox.ForeColor =
                    Infrastructure.Utility.DimGrayColor();
            }

            if (string.Compare(clientTelTextBox.Text, "تلفن اشتراک") != 0)
            {
                clientTelTextBox.ForeColor =
                    Infrastructure.Utility.WhiteColor();
            }
            else
            {
                clientTelTextBox.ForeColor =
                    Infrastructure.Utility.DimGrayColor();
            }

            if (string.Compare(clientAddressTextBox.Text, "آدرس اشتراک") != 0)
            {
                clientAddressTextBox.ForeColor =
                    Infrastructure.Utility.WhiteColor();
            }
            else
            {
                clientAddressTextBox.ForeColor =
                    Infrastructure.Utility.DimGrayColor();
            }
        }
예제 #19
0
        private void SaveButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;

            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                string errorMessage = string.Empty;

                #region Validation
                //-----
                if (string.IsNullOrWhiteSpace(dessertNameTextBox.Text) ||
                    string.Compare(dessertNameTextBox.Text, "نام دسر") == 0)
                {
                    errorMessage = "فیلد دسر تکمیل گردد!";
                }

                if (string.IsNullOrWhiteSpace(dessertPriceTextBox.Text) ||
                    string.Compare(dessertPriceTextBox.Text, "0 تومان") == 0)
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }

                    errorMessage +=
                        "فیلد مبلغ پیش غذا تکمیل گردد!";
                }

                if (string.IsNullOrWhiteSpace(descriptionTextBox.Text) ||
                    string.Compare(descriptionTextBox.Text, "توضیحات") == 0)
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }

                    errorMessage +=
                        "فیلد توضیحات تکمیل گردد!";
                }

                if (errorMessage != string.Empty)
                {
                    if (string.IsNullOrWhiteSpace(dessertNameTextBox.Text) ||
                        string.Compare(dessertNameTextBox.Text, "نام غذا") == 0)
                    {
                        dessertNameTextBox.Focus();
                        dessertNameTextBox.Clear();
                    }

                    else if (string.IsNullOrWhiteSpace(dessertPriceTextBox.Text) ||
                             string.Compare(dessertPriceTextBox.Text, "مبلغ غذا") == 0)
                    {
                        dessertPriceTextBox.Focus();
                        dessertPriceTextBox.Clear();
                    }

                    else if (string.IsNullOrWhiteSpace(descriptionTextBox.Text) ||
                             string.Compare(descriptionTextBox.Text, "توضیحات") == 0)
                    {
                        descriptionTextBox.Focus();
                        descriptionTextBox.Clear();
                    }

                    ErrorMessage(errorMessage);
                }

                if (string.IsNullOrEmpty(DessertImage))
                {
                    System.Windows.Forms.OpenFileDialog openFileDialog =
                        new System.Windows.Forms.OpenFileDialog
                    {
                        Filter = "JPEP (*.jpg)|*.jpg|" +
                                 "PNG (*.png)|*.png|" +
                                 "BMP (*.bmp)|*.bmp",
                        Title = "Load user picture ",
                    };

                    if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        DessertImage = openFileDialog.FileName;

                        dessertImagePicturBox.Image = System.Drawing.Image.FromFile(DessertImage);
                    }
                    return;
                }
                //-----
                #endregion /Validation

                errorMessageLabel.Visible = false;
                errorMessage = string.Empty;

                System.Windows.Forms.DialogResult dialogResult;

                dialogResult = Mbb.Windows.Forms.MessageBox.QuestionMessage
                                   (text: $"{DessertName} ثبت گردد؟",
                                   captiopn: "ثبت نوشیدنی",
                                   buttons: System.Windows.Forms.MessageBoxButtons.YesNo,
                                   defaultButton: System.Windows.Forms.MessageBoxDefaultButton.Button2,
                                   icon: System.Windows.Forms.MessageBoxIcon.Question,
                                   options: System.Windows.Forms.MessageBoxOptions.RightAlign |
                                   System.Windows.Forms.MessageBoxOptions.RtlReading);

                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    Models.DessertAndAppetizer dessertAndAppetizer =
                        dataBaseContext.DessertAndAppetizers
                        .Where(current => string.Compare(current.DessertName, DessertName, false) == 0)
                        .FirstOrDefault();

                    if (dessertAndAppetizer != null)
                    {
                        //errorMessage =
                        //	System.Environment.NewLine;

                        errorMessage =
                            $"{DessertName} در سیستم موجود است!";

                        ErrorMessage(errorMessage);
                        dessertNameTextBox.Focus();
                        dessertNameTextBox.SelectAll();
                        return;
                    }

                    else
                    {
                        RegisterDate = Infrastructure.Utility.PersianCalendar(System.DateTime.Now);

                        RegisterTime = Infrastructure.Utility.ShowTime();

                        dessertAndAppetizer =
                            new Models.DessertAndAppetizer
                        {
                            DessertName  = DessertName,
                            DessertPrice = $"{DessertPrice.ToString("#,0")} تومان",
                            Description  = Description,
                            DessertImage = System.IO.File.ReadAllBytes(DessertImage),
                            RegisterTime = RegisterDate + " " + RegisterTime,
                            UpdateTime   = UpdateTime,
                            NumberUpdate = int.Parse(NumberUpdate),
                        };
                        dataBaseContext.DessertAndAppetizers.Add(dessertAndAppetizer);
                        dataBaseContext.SaveChanges();

                        //-----جهت بارگذاری اطلاعات غذا در جدول داده
                        if (Resturant.MainForm.MenuListForm != null)
                        {
                            Resturant.MainForm.MenuListForm.DessertLoader();
                        }

                        string message =
                            $"{DessertName} ثبت گردید.";

                        Infrastructure.Utility.WindowsNotification
                            (message: message,
                            caption: Infrastructure.PopupNotificationForm.Caption.موفقیت,
                            picture: DessertImage);

                        AllClear();
                    }
                }
                else
                {
                    return;
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #20
0
        private void SaveButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                string errorMessage = string.Empty;

                if (string.IsNullOrEmpty(Username))
                {
                    errorMessage =
                        "وارد کردن شناسه کاربری الزامی است!";
                }
                if (string.IsNullOrEmpty(Email))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }

                    errorMessage +=
                        "وارد کردن ایمیل الزامی است!";
                }
                if (string.IsNullOrEmpty(Password))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }
                    errorMessage +=
                        "وارد کردن رمز عبور الزامی است!";
                }
                if (string.IsNullOrEmpty(PasswordConfirm))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }
                    errorMessage +=
                        "وارد کردن تایید رمز عبور الزامی است!";
                }
                if (errorMessage != string.Empty)
                {
                    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();
                    }
                    ErrorMessage(errorMessage);
                    return;
                }
                if (Infrastructure.Utility.PasswordSet(password: Password, passwordConfirm: PasswordConfirm) == false)
                {
                    errorMessage =
                        "عدم تطابق رمز!";
                    ErrorMessage(errorMessage);
                    passwordTextBox.Focus();
                    return;
                }
                else
                {
                    errorMessageLabel.Visible = false;
                }

                if (string.IsNullOrEmpty(UserImage))
                {
                    UserImage =
                        "D:\\Visual Studio Project\\C# Project\\Resturant\\Resturant\\Resources\\default_picture_512.png";
                }

                System.Windows.Forms.DialogResult dialogResult;

                dialogResult = Mbb.Windows.Forms.MessageBox.QuestionMessage
                                   (text: "کاربر مورد نظر ثبت گردد؟",
                                   captiopn: "ثبت کاربری",
                                   buttons: System.Windows.Forms.MessageBoxButtons.YesNo,
                                   defaultButton: System.Windows.Forms.MessageBoxDefaultButton.Button2,
                                   icon: System.Windows.Forms.MessageBoxIcon.Question,
                                   options: System.Windows.Forms.MessageBoxOptions.RightAlign |
                                   System.Windows.Forms.MessageBoxOptions.RtlReading);

                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    Models.User user =
                        dataBaseContext.Users
                        .Where(current => string.Compare(current.Username, Username) == 0)
                        .FirstOrDefault();

                    if (user != null)
                    {
                        errorMessage =
                            $"شناسه مورد نظر {Username} در سیستم موجود می باشد! لطفااز شناسه دیگری استفاده نمایید. ";

                        Mbb.Windows.Forms.MessageBox.InformationMessage(errorMessage);
                        return;
                    }
                    else
                    {
                        RegisterDate = Infrastructure.Utility.PersianCalendar(System.DateTime.Now);

                        RegisterTime = Infrastructure.Utility.ShowTime();

                        FullName = string.Concat(Infrastructure.Utility.TextFixed(FirstName) + " " + Infrastructure.Utility.TextFixed(LastName));
                        user     =
                            new Models.User
                        {
                            IsActive         = true,
                            IsAdministrator  = false,
                            FullName         = FullName,
                            Username         = Username,
                            Email            = Email,
                            Password         = Password,
                            UserPicture      = System.IO.File.ReadAllBytes(UserImage),
                            RegistrationTime = RegisterTime + " " + RegisterDate,
                        };
                        dataBaseContext.Users.Add(user);
                        dataBaseContext.SaveChanges();
                    }
                }
                else
                {
                    return;
                }

                string message =
                    $"شناسه کاربری با نام {Username} ثبت گردید.";

                Infrastructure.Utility.WindowsNotification
                    (message: message,
                    caption: Infrastructure.PopupNotificationForm.Caption.موفقیت,
                    picture: UserImage);

                AllClear();
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #21
0
        public static void Administrator()
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                string adminPic =
                    "D:\\Visual Studio Project\\C# Project\\Resturant\\Resturant\\Resources\\AdminUser.png";

                string user =
                    "******";

                string password =
                    "******";

                string email =
                    "*****@*****.**";
                bool isAdmin  = true;
                bool isActive = true;

                Models.User adminUser =
                    dataBaseContext.Users
                    .Where(admin => string.Compare(user, admin.Username, true) == 0)
                    .FirstOrDefault();

                if (adminUser == null)
                {
                    adminUser =
                        new Models.User
                    {
                        IsActive        = isActive,
                        IsAdministrator = isAdmin,

                        Username         = user,
                        Password         = password,
                        Email            = email,
                        UserPicture      = System.IO.File.ReadAllBytes(adminPic),
                        RegistrationTime = "00:00:00 " + "0000/00/00",
                    };
                    dataBaseContext.Users.Add(adminUser);
                }

                else
                {
                    if (adminUser.IsActive == false)
                    {
                        adminUser.IsActive = true;
                    }

                    if (adminUser.IsAdministrator == false)
                    {
                        adminUser.IsAdministrator = true;
                    }
                }
                dataBaseContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                Mbb.Windows.Forms.MessageBox.ErrorMessage(ex.Message);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #22
0
        private void LoginButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                string errorMessage = string.Empty;

                if (string.IsNullOrEmpty(UsernameEmail))
                {
                    errorMessage =
                        "نام کاربری یا پست الکترونیکی را وارد کنید!!";
                }
                if (string.IsNullOrEmpty(Password))
                {
                    if (string.IsNullOrEmpty(errorMessage) == false)
                    {
                        errorMessage +=
                            System.Environment.NewLine;
                    }
                    errorMessage +=
                        "رمز عبور را وارد نمایید.";
                }

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    if (string.IsNullOrEmpty(UsernameEmail))
                    {
                        usernameEmailTextBox.Focus();
                    }
                    else if (string.IsNullOrEmpty(Password) == false)
                    {
                        passwordTextBox.Focus();
                    }

                    Mbb.Windows.Forms.MessageBox.Show
                        (text: errorMessage,
                        caption: "خطای ورودی",
                        icon: Mbb.Windows.Forms.MessageBoxIcon.Error,
                        button: Mbb.Windows.Forms.MessageBoxButtons.Ok);
                    return;
                }

                if (ApprovalUsername(text: UsernameEmail) == false && ApprovalEmail(text: UsernameEmail) == false)
                {
                    i++;
                    errorMessage =
                        "شناسه کاربری و/یا رمز عبور صحیح نمی باشد!";
                    Mbb.Windows.Forms.MessageBox.Show
                        (text: errorMessage,
                        caption: "خطای ورودی",
                        icon: Mbb.Windows.Forms.MessageBoxIcon.Error,
                        button: Mbb.Windows.Forms.MessageBoxButtons.Ok);
                    if (i >= 2)
                    {
                        forgetPasswordLinkLabel.Visible = true;
                    }
                    return;
                }
                else if (ApprovalUsername(text: UsernameEmail) == true && ApprovalEmail(text: UsernameEmail) == false)
                {
                    Models.User user =
                        dataBaseContext.Users
                        .Where(current => string.Compare(current.Username, UsernameEmail, true) == 0)
                        .FirstOrDefault();


                    if (string.Compare(user.Password, Password, true) != 0)
                    {
                        i++;
                        errorMessage =
                            "شناسه کاربری و/یا رمز عبور صحیح نمی باشد!";
                        Mbb.Windows.Forms.MessageBox.Show
                            (text: errorMessage, caption: "خطای ورودی",
                            icon: Mbb.Windows.Forms.MessageBoxIcon.Error,
                            button: Mbb.Windows.Forms.MessageBoxButtons.Ok);

                        if (i >= 2)
                        {
                            forgetPasswordLinkLabel.Visible = true;
                        }
                        return;
                    }
                    else
                    {
                        this.Hide();
                        Program.AuthenticatedUser = user;
                        SaveLoginHistory(user);

                        WelcomeUserForm welComeUserForm =
                            new WelcomeUserForm();

                        welComeUserForm.ShowDialog();

                        Program.MainForm.FormClosed += LogOut;
                    }
                }

                else if (ApprovalUsername(text: UsernameEmail) == false && ApprovalEmail(text: UsernameEmail) == true)
                {
                    Models.User user =
                        dataBaseContext.Users
                        .Where(current => string.Compare(current.Email, UsernameEmail, false) == 0)
                        .FirstOrDefault();

                    if (string.Compare(user.Password, Password, true) != 0)
                    {
                        i++;
                        errorMessage =
                            "شناسه کاربری و/یا رمز عبور صحیح نمی باشد!";
                        Mbb.Windows.Forms.MessageBox.Show
                            (text: errorMessage, caption: "خطای ورودی",
                            icon: Mbb.Windows.Forms.MessageBoxIcon.Error,
                            button: Mbb.Windows.Forms.MessageBoxButtons.Ok);
                        if (i >= 2)
                        {
                            forgetPasswordLinkLabel.Visible = true;
                        }
                    }

                    else
                    {
                        this.Hide();
                        Program.AuthenticatedUser = user;
                        SaveLoginHistory(user);

                        WelcomeUserForm welComeUserForm =
                            new WelcomeUserForm();

                        welComeUserForm.ShowDialog();
                        Program.MainShow();
                        Program.MainForm.FormClosed += LogOut;
                    }
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #23
0
        private void LoginButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                string errorMessage = string.Empty;

                if (string.IsNullOrWhiteSpace(usernameTextBox.Text) ||
                    string.Compare(usernameTextBox.Text, "Username") == 0)
                {
                    errorMessage =
                        "شناسه کاربری را وارد نمایید!";
                }

                if (string.IsNullOrWhiteSpace(passwordTextBox.Text) ||
                    string.Compare(passwordTextBox.Text, "Password") == 0)
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }

                    errorMessage +=
                        "رمز عبور را وارد نمایید!";
                }

                if (errorMessage != string.Empty)
                {
                    if (string.IsNullOrWhiteSpace(usernameTextBox.Text) ||
                        string.Compare(usernameTextBox.Text, "Username") == 0)
                    {
                        usernameTextBox.Focus();
                    }

                    else if (string.IsNullOrWhiteSpace(passwordTextBox.Text) ||
                             string.Compare(passwordTextBox.Text, "Password") == 0)
                    {
                        passwordTextBox.Focus();
                    }
                    ErrorMessage(errorMessage);
                    return;
                }

                Models.User foundUser =
                    dataBaseContext.Users
                    .Where(current => string.Compare(current.Username, usernameTextBox.Text, true) == 0)
                    .FirstOrDefault();

                if (foundUser == null)
                {
                    errorMessage =
                        "شناسه کاربری و/یا رمز عبور صحیح نمی باشد!";

                    ErrorMessage(errorMessage);
                    usernameTextBox.Focus();
                    return;
                }

                if (string.Compare(foundUser.Password, passwordTextBox.Text, false) != 0)
                {
                    errorMessage =
                        "شناسه کاربری و/یا رمز عبور صحیح نمی باشد!";
                    ErrorMessage(errorMessage);
                    passwordTextBox.Focus();
                    return;
                }
                this.Hide();
                Program.AuthenticatedUser = foundUser;
                SaveLoginHistory(foundUser);

                WelcomeForm welcomeForm =
                    new WelcomeForm();

                welcomeForm.ShowDialog();

                Program.MainForm.FormClosed += LogOut;
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #24
0
        //-----
        #endregion /ClientAddressTextBox

        #region SaveButton_Click
        private void SaveButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                #region Validation
                //===============
                int    count        = 0;
                string errorMessage = string.Empty;

                if (string.IsNullOrEmpty(SubscriptionCode.ToString()) || SubscriptionCode == 0)
                {
                    errorMessage =
                        "انتخاب کد اشتراک الزامی است!";
                    count++;
                }

                if (string.IsNullOrEmpty(ClientName))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }
                    errorMessage += "فیلد نام مشترک تکمیل گردد! ";
                    count++;
                }

                if (string.IsNullOrEmpty(ClientTel))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }
                    errorMessage += "فیلد تلفن مشترک تکمیل گردد! ";
                    count++;
                }

                if (string.IsNullOrEmpty(ClientAddress))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }
                    errorMessage += "فیلد آدرس مشترک تکمیل گردد! ";
                    count++;
                }

                if (errorMessage != string.Empty)
                {
                    if (count == 1)
                    {
                        this.Size = new System.Drawing.Size(490, 240);
                        ErrorMessage(errorMessage);
                    }
                    else if (count == 2)
                    {
                        this.Size = new System.Drawing.Size(490, 260);
                        ErrorMessage(errorMessage);
                    }
                    else if (count == 3)
                    {
                        this.Size = new System.Drawing.Size(490, 280);
                        ErrorMessage(errorMessage);
                    }
                    else if (count == 4)
                    {
                        this.Size = new System.Drawing.Size(490, 300);
                        ErrorMessage(errorMessage);
                    }
                    return;
                }
                //===================
                #endregion /Validation

                System.Windows.Forms.DialogResult dialogResult;

                dialogResult = Mbb.Windows.Forms.MessageBox.QuestionMessage
                                   (text: "مشترک مورد نظر ثبت گردد؟",
                                   captiopn: "ثبت مشتری",
                                   buttons: System.Windows.Forms.MessageBoxButtons.YesNo,
                                   defaultButton: System.Windows.Forms.MessageBoxDefaultButton.Button2,
                                   icon: System.Windows.Forms.MessageBoxIcon.Question,
                                   options: System.Windows.Forms.MessageBoxOptions.RightAlign |
                                   System.Windows.Forms.MessageBoxOptions.RtlReading);

                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    Picture = string.Empty;
                    Models.Client client =
                        dataBaseContext.Clients
                        .Where(current => string.Compare(current.ClientAddress, ClientAddress) == 0)
                        .FirstOrDefault();

                    if (client != null)
                    {
                        newCodeButton.Focus();
                        return;
                    }
                    else
                    {
                        client =
                            new Models.Client
                        {
                            SubscriptionCode = SubscriptionCode,
                            ClientName       = ClientName,
                            ClientTel        = ClientTel,
                            ClientAddress    = ClientAddress,
                            OrderDate        = OrderDate,
                        };
                        dataBaseContext.Clients.Add(client);
                        dataBaseContext.SaveChanges();
                    }
                }
                else
                {
                    return;
                }

                string message =
                    $"مشترک با کد اشتراک {SubscriptionCode} ثبت گردید.";

                Infrastructure.Utility.WindowsNotification
                    (message: message,
                    caption: Infrastructure.PopupNotificationForm.Caption.موفقیت);

                if (Resturant.MainForm.ClientsListForm != null)
                {
                    Resturant.MainForm.ClientsListForm.ClientLoader();
                }

                AllClear();
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #25
0
        private void ShowInformations(string foundedUsername)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                Models.User user =
                    dataBaseContext.Users
                    .Where(current => string.Compare(current.Username, foundedUsername) == 0)
                    .FirstOrDefault();

                if (user != null)
                {
                    if (string.Compare(user.Username, "administrator") == 0 || string.Compare(user.Username, Program.AuthenticatedUser.Username) == 0)
                    {
                        return;
                    }
                    else
                    {
                        usernameLabel.Text   = user.Username;
                        AccessLeve_FirstLoad = user.Access_Level;

                        switch (AccessLeve_FirstLoad)
                        {
                        case "مدیریت":
                            administratorRadioButton.Checked = true;
                            employeedRadioButton.Checked     = false;
                            serviceForceRadioButton.Checked  = false;
                            simpleUserRadioButton.Checked    = false;
                            break;

                        case "کارمند":
                            administratorRadioButton.Checked = false;
                            employeedRadioButton.Checked     = true;
                            serviceForceRadioButton.Checked  = false;
                            simpleUserRadioButton.Checked    = false;
                            break;

                        case "نیروی خدمات":
                            administratorRadioButton.Checked = false;
                            employeedRadioButton.Checked     = false;
                            serviceForceRadioButton.Checked  = true;
                            simpleUserRadioButton.Checked    = false;
                            break;

                        case "کاربر ساده":
                            administratorRadioButton.Checked = false;
                            employeedRadioButton.Checked     = false;
                            serviceForceRadioButton.Checked  = false;
                            simpleUserRadioButton.Checked    = true;
                            break;

                        default:
                            break;
                        }

                        Activation_FirstLoad       = user.IsActive;
                        activationCheckBox.Checked = user.IsActive;

                        var byteImage = user.User_Image;
                        using (System.IO.MemoryStream ms = new System.IO.MemoryStream(byteImage))
                        {
                            userImagePictureBox.BackgroundImage = System.Drawing.Image.FromStream(ms);
                        }
                        updateButton.Enabled = false;
                    }
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #26
0
        //-----
        #region Administrator
        public static void Administrator()
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();
                string adminPic =
                    "D:\\Visual Studio Project\\C# Project\\ComputerServices\\Computer Services\\Resources\\AdminUser.png";
                Models.User adminUser =
                    dataBaseContext.Users
                    .Where(current => string.Compare(current.Username, "administrator", true) == 0)
                    .FirstOrDefault();

                if (adminUser == null)
                {
                    adminUser =
                        new Models.User
                    {
                        IsActive          = true,
                        IsAdministrator   = true,
                        Username          = "******",
                        Email             = "null",
                        Password          = "******",
                        Description       = "null",
                        User_Image        = System.IO.File.ReadAllBytes(adminPic),
                        First_Name        = "null",
                        Last_Name         = "null",
                        Telephone         = "null",
                        National_Code     = "null",
                        Address           = "null",
                        Marital_Status    = "null",
                        Registration_Time = "00:00:00",
                        Registration_Date = "0000/00/00",
                    };
                    dataBaseContext.Users.Add(adminUser);
                }

                else
                {
                    if (adminUser.IsActive == false)
                    {
                        adminUser.IsActive = true;
                    }

                    if (adminUser.IsAdministrator == false)
                    {
                        adminUser.IsAdministrator = true;
                    }
                }
                dataBaseContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #27
0
        //-----
        #endregion /ClientAddressTextBox

        #region SaveEditButton_Click
        private void SaveEditButton_Click(object sender, System.EventArgs e)
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();

                #region Validation
                //===============
                int    count        = 0;
                string errorMessage = string.Empty;

                if (string.IsNullOrEmpty(ClientName))
                {
                    errorMessage += "فیلد نام مشترک تکمیل گردد! ";
                    count++;
                }

                if (string.IsNullOrEmpty(ClientTel))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }
                    errorMessage += "فیلد تلفن مشترک تکمیل گردد! ";
                    count++;
                }

                if (string.IsNullOrEmpty(ClientAddress))
                {
                    if (errorMessage != string.Empty)
                    {
                        errorMessage +=
                            System.Environment.NewLine + "       ";
                    }
                    errorMessage += "فیلد آدرس مشترک تکمیل گردد! ";
                    count++;
                }

                if (errorMessage != string.Empty)
                {
                    if (count == 1)
                    {
                        this.Size = new System.Drawing.Size(490, 250);
                        ErrorMessage(errorMessage);
                    }
                    else if (count == 2)
                    {
                        this.Size = new System.Drawing.Size(490, 270);
                        ErrorMessage(errorMessage);
                    }
                    else if (count == 3)
                    {
                        this.Size = new System.Drawing.Size(490, 290);
                        ErrorMessage(errorMessage);
                    }
                    return;
                }
                //===================
                #endregion /Validation

                System.Windows.Forms.DialogResult dialogResult;

                dialogResult = Mbb.Windows.Forms.MessageBox.QuestionMessage
                                   (text: "مشترک مورد نظر به روز گردد؟",
                                   captiopn: "به روز رسانی",
                                   buttons: System.Windows.Forms.MessageBoxButtons.YesNo,
                                   defaultButton: System.Windows.Forms.MessageBoxDefaultButton.Button2,
                                   icon: System.Windows.Forms.MessageBoxIcon.Question,
                                   options: System.Windows.Forms.MessageBoxOptions.RightAlign |
                                   System.Windows.Forms.MessageBoxOptions.RtlReading);

                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    Models.Client client =
                        dataBaseContext.Clients
                        .Where(current => string.Compare(current.SubscriptionCode.ToString(), subscriptionCodeLabel.Text) == 0)
                        .FirstOrDefault();
                    if (client != null)
                    {
                        client.ClientName    = ClientName;
                        client.ClientTel     = ClientTel;
                        client.ClientAddress = ClientAddress;

                        dataBaseContext.SaveChanges();
                    }
                }
                else
                {
                    return;
                }

                string message =
                    $"اطلاعات مشترک به روز رسانی شد!.";

                Infrastructure.Utility.WindowsNotification
                    (message: message,
                    caption: Infrastructure.PopupNotificationForm.Caption.موفقیت);

                if (Resturant.MainForm.ClientsListForm != null)
                {
                    Resturant.MainForm.ClientsListForm.ClientLoader();
                }
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.PopupNotification(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #28
0
        //------------------------------------------------------------------
        #region Administrator
        public static void Administrator()
        {
            Models.DataBaseContext dataBaseContext = null;
            try
            {
                dataBaseContext =
                    new Models.DataBaseContext();
                string adminPic =
                    "D:\\Visual Studio Project\\Personal Project\\HOOKAH_SALON\\HOOKAH_SALON\\Resources\\AdminUser.png";
                Models.User adminUser =
                    dataBaseContext.Users
                    .Where(current => string.Compare(current.Username, "administrator", true) == 0)
                    .FirstOrDefault();

                if (adminUser == null)
                {
                    adminUser =
                        new Models.User
                    {
                        IsActive          = true,
                        Access_Level      = "مدیریت",
                        Username          = "******",
                        Email             = "-",
                        Password          = "******",
                        Description       = "-",
                        User_Image        = System.IO.File.ReadAllBytes(adminPic),
                        First_Name        = "Administrator",
                        Last_Name         = " ",
                        Telephone         = "-",
                        National_Code     = "-",
                        Address           = "-",
                        Marital_Status    = "-",
                        Registration_Time = "-",
                        Registration_Date = "-",
                    };
                    dataBaseContext.Users.Add(adminUser);
                }
                else
                {
                    if (adminUser.IsActive == false)
                    {
                        adminUser.IsActive = true;
                    }
                    if (string.Compare(adminUser.Access_Level, "کارمند") == 0 || string.Compare(adminUser.Access_Level, "نیروی خدمات") == 0)
                    {
                        adminUser.Access_Level = "مدیریت";
                    }
                }
                dataBaseContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                Infrastructure.Utility.ExceptionShow(ex);
            }
            finally
            {
                if (dataBaseContext != null)
                {
                    dataBaseContext.Dispose();
                    dataBaseContext = null;
                }
            }
        }
예제 #29
0
        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;
                }
            }
        }