Beispiel #1
0
        private void deleteRestrictionButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("آیا از حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialogResult == DialogResult.Yes)
            {
                try {
                    selectedRow = validationDataGridView.CurrentCell.RowIndex;

                    SqlManipulator  sql                = new SqlManipulator();
                    DataGridViewRow newDataRow         = validationDataGridView.Rows[selectedRow];
                    validationTable deletedRestriction = new validationTable();


                    deletedRestriction.City        = (long)newDataRow.Cells[2].Value;
                    deletedRestriction.startDate   = (long)newDataRow.Cells[3].Value;
                    deletedRestriction.enDate      = (long)newDataRow.Cells[4].Value;
                    deletedRestriction.id          = (long)newDataRow.Cells[0].Value;
                    deletedRestriction.description = (String)newDataRow.Cells[1].Value;
                    sql.removeRestriction(deletedRestriction);
                    var data = sql.getValidationData();
                    makeValidationTable(data);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Beispiel #2
0
 private void setPlaceComboBox()
 {
     AccountTypeComboBox.SelectedIndex = 0;
     placeComboBox.Items.Clear();
     if (!login.permission)
     {
         placeComboBox.Items.Add(new ComboboxItem(login.cityName, login.cityID));
         placeComboBox.SelectedIndex = 0;
         placeComboBox.Enabled       = false;
     }
     else
     {
         try
         {
             SqlManipulator sql    = new SqlManipulator();
             var            cities = sql.queryCities();
             foreach (var city in cities)
             {
                 placeComboBox.Items.Add(new ComboboxItem(city.CityName, city.Id));
             }
             placeComboBox.Enabled       = true;
             placeComboBox.SelectedIndex = 0;
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Beispiel #3
0
        private void ManagerForm_Load(object sender, EventArgs e)
        {
            ExtensionMethods.DoubleBuffered(this.usersDataGridView, true);
            selectedRow = 0;
            SqlManipulator sql = new SqlManipulator();

            try
            {
                makeTableUsers(sql.getDataLogin());
                //usersDataGridView.Columns[0].Visible = false;
                var cities = sql.queryCities();
                cityComboBox.DataSource = cities;

                // this.cityTableTableAdapter.Fill(this.daftarDataSet1.CityTable);
                makeTable(sql.getDataCity());
                makeTableUsers(sql.getDataLogin());
                makeValidationTable(sql.getValidationData());
                startendDate                = sql.findMaxminMonthDay(0);
                this.versionTextBox.Text    = global.currentVersion.ToString();
                this.versionTextBox.Enabled = false;
                DGV_SetStyle(this.cityDataGridView);


                changeCityDGVname();

                changeColumnName();
                selectedRow = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #4
0
        private void removeButton_Click(object sender, EventArgs e)
        {
            try {
                DialogResult dialogResult = MessageBox.Show("آیا از حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.Yes)
                {
                    selectedRow = usersDataGridView.CurrentCell.RowIndex;
                    SqlManipulator  sql          = new SqlManipulator();
                    DataGridViewRow newDataRow   = usersDataGridView.Rows[selectedRow];
                    UserTable       deletePerson = new UserTable();
                    deletePerson.Id       = (int)newDataRow.Cells[0].Value;
                    deletePerson.User     = (string)newDataRow.Cells[1].Value;
                    deletePerson.Password = (string)newDataRow.Cells[2].Value;

                    if (login.Id == deletePerson.Id)
                    {
                        MessageBox.Show("این کاربر مجوز حذف خود را ندارد", "پیغام سیستم ", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        return;
                    }
                    sql.removeUser(deletePerson);
                    var logindata = sql.getDataLogin();
                    makeTableUsers(logindata);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
 private void setComboBoxCity()
 {
     if (login.permission)
     {
         try {
             cityComboBox.Enabled = true;
             SqlManipulator sql    = new SqlManipulator();
             var            cities = sql.queryCities();
             foreach (var city in cities)
             {
                 cityComboBox.Items.Add(new ComboboxItem(city.CityName, city.Id));
             }
             cityComboBox.SelectedIndex = 0;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
             MessageBox.Show("شهری در پایگاه داده وجود ندارد");
         }
     }
     else
     {
         cityComboBox.Items.Add(new ComboboxItem(login.cityName, login.cityID));
         cityComboBox.SelectedIndex = 0;
         cityComboBox.Enabled       = false;
     }
 }
Beispiel #6
0
        private void editButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!inputValidation())
                {
                    return;
                }
                Utility        utl       = new Utility();
                SqlManipulator sql       = new SqlManipulator();
                DaftarTable    newDaftar = new DaftarTable();
                if (login.permission)
                {
                    var itm = (ComboboxItem)placeComboBox.SelectedItem;
                    login.cityID = itm.Value;
                }
                else
                {
                    newDaftar.CityID = login.cityID;
                }
                newDaftar.Id = data.Id;

                //var item = (ComboboxItem)placeComboBox.SelectedItem;
                //newDaftar.CityID = item.Value;
                newDaftar.Refund      = Convert.ToInt64(this.refundTextBox.Text);
                newDaftar.AccountType = this.AccountTypeComboBox.SelectedItem.ToString();
                //  newDaftar.BillDetailCode = Convert.ToInt64(this.billDetailCodetextBox.Text);
                newDaftar.CodeBudget = Convert.ToInt64(this.BudgetCodetextBox.Text);
                //newDaftar.Date = this.dateMaskedTextBox.Text;
                newDaftar.PlaceName = placeComboBox.SelectedItem.ToString();
                // newDaftar.RealDate = utl.changeToRealDate(newDaftar.Date);
                newDaftar.Deposit            = Convert.ToInt64(this.DepositTextBox.Text);
                newDaftar.RealDate           = data.RealDate;
                newDaftar.DepositDetail      = Convert.ToInt64(this.DepositDetailtextBox.Text);
                newDaftar.DepositOwnerDetail = this.DepositOwnerDetailTextBox.Text;
                newDaftar.CityID             = data.CityID;

                if (sql.isRestricted(newDaftar, login.permission))
                {
                    MessageBox.Show("دسترسی شما به این تاریخ توسط مدیر سیستم محدود شده است", "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                ;
                Reporter rpt = new Reporter(sql.update(newDaftar, godmode), (int)errorImages.info);
                rpt.Show();
                form.refreshLastState(lastState, pageNumber, false);
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ورودی های خود را کنترل نمائید", "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #7
0
        private void sendButton_Click(object sender, EventArgs e)
        {
            SqlManipulator sql = new SqlManipulator();

            if (sql.sendMessages(this.MessageRichTextBox.Text))
            {
                MessageBox.Show("پیغام با موفقیت ارسال شد ، در ورود جدید به کاربران پیغام شما نمایش خواهد داده شد  ");
            }
            else
            {
                MessageBox.Show("خطایی رخ داده است ");
            };
        }
Beispiel #8
0
        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
            if (e.TabPage == tabPage1)
            {
                selectedRow = 0;

                SqlManipulator sql = new SqlManipulator();
                try
                {
                    makeTableUsers(sql.getDataLogin());

                    /// usersDataGridView.Columns[0].Visible = false;
                    var cities = sql.queryCities();
                    cityComboBox.DataSource = cities;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            if (e.TabPage == tabPage2)

            {
                selectedRow = 0;
                SqlManipulator sql = new SqlManipulator();
                makeTable(sql.getDataCity());
            }
            if (e.TabPage == tabPage4)
            {
                try {
                    SqlManipulator sql = new SqlManipulator();
                    makeValidationTable(sql.getValidationData());
                    var cities = sql.queryCities();
                    validCityComboBox.DataSource = cities;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Beispiel #9
0
 private void updateButton_Click(object sender, EventArgs e)
 {
     try {
         if (activateCheckBox.Checked)
         {
             SqlManipulator sql = new SqlManipulator();
             if (sql.sendUpdateNotify(Int32.Parse(this.versionTextBox.Text.ToString())))
             {
                 MessageBox.Show("با  موفقیت پیام بروزرسانی ارسال شد ، کاربران ملزم به استفاده از  نسخه جدید می باشند ");
             }
         }
         else
         {
             this.versionTextBox.Text = global.currentVersion.ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Beispiel #10
0
        private void addButton_Click(object sender, EventArgs e)
        {
            UserTable newLogin = new UserTable();

            newLogin.Name         = nameTextBox.Text;
            newLogin.Family       = familyTextBox.Text;
            newLogin.User         = userNameTextBox.Text;
            newLogin.Password     = passWordTextBox.Text;
            newLogin.City         = Convert.ToInt64(cityComboBox.SelectedValue);
            newLogin.Permission   = persmissionCheckBox.Checked;
            newLogin.AdminVersion = AdminCheckBox.Checked;
            newLogin.Update       = false;
            newLogin.Messages     = " ";
            newLogin.Version      = global.currentVersion;

            SqlManipulator sql = new SqlManipulator();
            Reporter       rpt = new Reporter(sql.addUser(newLogin), (int)errorImages.info);

            rpt.Show();
            makeTableUsers(sql.getDataLogin());
        }
Beispiel #11
0
        private void importAllButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (login.permission)
                {
                    var            dataToimport = excelData;
                    SqlManipulator sql          = new SqlManipulator();
                    Utility        util         = new Utility();
                    foreach (var data in dataToimport)
                    {
                        var          convertedData = util.convertYekeQuery(data.ToList());
                        var          query         = convertedData.AsQueryable();
                        ComboboxItem itm           = (ComboboxItem)cityComboBox.SelectedItem;
                        long         id            = itm.Value;
                        sql.excelToSqlCopy(query, id);
                    }
                }
                else
                {
                    var            dataToimport = excelData;
                    SqlManipulator sql          = new SqlManipulator();
                    Utility        util         = new Utility();
                    foreach (var data in dataToimport)
                    {
                        var convertedData = util.convertYekeQuery(data.ToList());
                        var query         = convertedData.AsQueryable();

                        sql.excelToSqlCopy(query, login.cityID);
                    }
                }

                this.mainForm.refreshDGV();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Data.ToString());
            }
            this.Hide();
        }
Beispiel #12
0
        private void addRestriction()
        {
            try
            {
                validationTable valid = new validationTable();

                DateTime endTime = endDateTimePickerX1.SelectedDateInDateTime;

                StartEndMonthClass date = new StartEndMonthClass();

                date.endDate = Convert.ToInt64(endTime.ToFa("yyyyMMdd"));

                valid.startDate = startendDate.min;
                valid.enDate    = date.endDate;
                valid.City      = Convert.ToInt64(validCityComboBox.SelectedValue);
                SqlManipulator sql = new SqlManipulator();

                //if (this.lockAllCitiesCheckBox.Checked == true)
                //{
                //    var cities = sql.getDataCity();
                //    foreach(var city in cities)
                //    {

                //    }
                //}
                var           cityName  = sql.getCityName(valid.City);
                FarsiDateUtil startDate = new FarsiDateUtil(startendDate.min.ToString());
                FarsiDateUtil endDate   = new FarsiDateUtil(date.endDate.ToString());
                valid.description = "قفل" + " " + cityName + "  " + endDate.MonthName + endDate.Year;
                Reporter rpt = new Reporter(sql.addValidation(valid), (int)errorImages.info);
                rpt.Show();
                makeValidationTable(sql.getValidationData());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #13
0
 private void addCityToFormManagerButton_Click(object sender, EventArgs e)
 {
     try {
         CityTable newCity = new CityTable();
         newCity.CityName = CityTextBox.Text;
         newCity.Id       = Convert.ToInt64(IDTextBox.Text);
         SqlManipulator sql = new SqlManipulator();
         if (sql.addCity(newCity))
         {
             makeTable(sql.getDataCity());
             MessageBox.Show("با موفقیت شهر مورد نظر اضافه گردید");
             mainForm.setCityComboBox();
         }
         else
         {
             MessageBox.Show("خطا");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Beispiel #14
0
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("آیا از حذف مطمئن هستید؟", "هشدار", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialogResult == DialogResult.Yes)
            {
                try {
                    selectedRow = cityDataGridView.CurrentCell.RowIndex;
                    SqlManipulator  sql         = new SqlManipulator();
                    DataGridViewRow newDataRow  = cityDataGridView.Rows[selectedRow];
                    CityTable       deletedCity = new CityTable();

                    deletedCity.Id       = (long)newDataRow.Cells[1].Value;
                    deletedCity.CityName = (string)newDataRow.Cells[0].Value;
                    sql.removeCity(deletedCity);
                    var cityData = sql.getDataCity();
                    makeTable(cityData);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Beispiel #15
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            try
            {
                var cn = Properties.Settings.Default.MainConnectionString;
                if (IsServerConnected(cn))
                {
                    UserManagerDataClassesDataContext db = new UserManagerDataClassesDataContext(cn);
                    foreach (var q in db.UserTables)
                    {
                        if (q.User == this.UserNametextBox.Text && q.Password == this.PasswordTextBox.Text)
                        {
                            this.Hide();
                            LoginInfo login = new LoginInfo();
                            login.cityID       = q.City;
                            login.Name         = q.Name;
                            login.Id           = q.Id;
                            login.family       = q.Family;
                            login.permission   = q.Permission.Value;
                            login.user         = q.User;
                            login.update       = q.Update.Value;
                            login.messages     = q.Messages;
                            login.version      = q.Version ?? default(int);
                            login.adminVersion = q.AdminVersion ?? default(bool);
                            if (login.version > currentVersion && !login.adminVersion)
                            {
                                MessageBox.Show("نسخه شما بروز نیست . آخرین نسخه بروز شده را نصب کنید ", "پیغام",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Stop);
                                this.Close();
                                return;
                            }


                            SqlManipulator sql = new SqlManipulator();
                            if (!login.adminVersion)
                            {
                                if (login.update)
                                {
                                    MessageBox.Show(login.messages, "پیغام ",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                    try {
                                        sql.MessagesSeenStatus(false, login);
                                    }
                                    catch (Exception)
                                    { MessageBox.Show("خطا در  پیغام"); }
                                }
                            }
                            string cityName = sql.getCityName(login.cityID);
                            login.cityName = cityName;
                            form.setLoginData(login);

                            Properties.Settings.Default.LastUser = this.UserNametextBox.Text;

                            tmr = new Timer();

                            //set time interval 3 sec

                            tmr.Interval = 3500;

                            //starts the timer
                            formwait = new SplashScreenForm();
                            formwait.Show();
                            tmr.Start();

                            tmr.Tick  += tmr_Tick;
                            permission = q.Permission.Value;
                            Properties.Settings.Default.Save();
                            return;
                        }
                    }
                    MessageBox.Show("نام کاربری و گذر واژه فاقد اعتبار است", "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    MessageBox.Show("ارتباط با سرور قطع است ، تنظیمات سرور را بررسی کنید", "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);

                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #16
0
        private void importButton1_Click(object sender, EventArgs e)
        {
            try
            {
                if (refundRadioButton.Checked == false && depositRadioButton.Checked == false)
                {
                    MessageBox.Show("  لطفا نوع فایل را انتخاب  نمایید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                // StartProgress();
                if (login.permission)
                {
                    var dataToimport = excelData[excelMonthscomboBox.SelectedIndex];

                    SqlManipulator sql = new SqlManipulator();


                    ExcelManipulatorcs excel = new ExcelManipulatorcs();
                    var query = excel.dataCorrection(dataToimport);

                    var  itm = (ComboboxItem)cityComboBox.SelectedItem;
                    long id  = itm.Value;

                    if (this.refundRadioButton.Checked)
                    {
                        var      report = sql.refundFromFile(query, id);
                        Reporter rpt    = new Reporter(report, Convert.ToInt32(errorImages.info));
                        rpt.Show();
                    }
                    if (this.depositRadioButton.Checked)
                    {
                        sql.excelToSqlCopy(query, id);
                    }

                    this.mainForm.refreshDGV();
                }
                else
                {
                    Utility        util         = new Utility();
                    var            dataToimport = excelData[excelMonthscomboBox.SelectedIndex];
                    SqlManipulator sql          = new SqlManipulator();

                    var convertedData = util.convertYekeQuery(dataToimport.ToList());
                    convertedData = util.convertToRealDate(convertedData);

                    var query = convertedData.AsQueryable();

                    if (this.refundRadioButton.Checked)
                    {
                        var      report = sql.refundFromFile(query, login.cityID);
                        Reporter rpt    = new Reporter(report, Convert.ToInt32(errorImages.info));
                        rpt.Show();
                    }
                    if (this.depositRadioButton.Checked)
                    {
                        sql.excelToSqlCopy(query, login.cityID);
                    }


                    this.mainForm.refreshDGV();
                }
                excelData.Clear();

                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            //  CloseProgress();
        }