Exemplo n.º 1
0
        private void btnDeleteMotorOil_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new StimulsoftEntities())
                {
                    int x = Convert.ToInt16(dgShow.CurrentRow.Cells[4].Value.ToString());

                    ServicesPrice del = context.ServicesPrice.Where(current => current.Id == x).FirstOrDefault();
                    context.ServicesPrice.Remove(del);
                    context.SaveChanges();
                    lblError.ForeColor = Color.Green;
                    lblError.Text      = "خدمت با موفقیت حذف شد";
                    context.Dispose();



                    Refresh_Price();
                    comGroup.Text       = "";
                    txtServiceName.Text = "";
                    txtKindKala.Text    = "";
                    txtServisPrice.Text = "";
                }
            }
            catch (Exception)
            {
                lblError.ForeColor = Color.Red;
                lblError.Text      = "عملیات حذف با مشکل مواجه شد";
            }
        }
Exemplo n.º 2
0
        private void btnUpdatePriceOilMotor_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new StimulsoftEntities())
                {
                    Int64 price   = Convert.ToInt64(txtServisPrice.Text);
                    var   service = context.ServicesPrice.Where(current => current.ServisKind == comGroup.Text && current.ServiceKala == txtKindKala.Text && current.ServiseName == txtServiceName.Text && current.ServicePrice == price).ToList();
                    if (service.Count == 0)
                    {
                        int x      = Convert.ToInt16(dgShow.CurrentRow.Cells[4].Value.ToString());
                        var update = context.ServicesPrice.Where(current => current.Id == x).FirstOrDefault();
                        if (update != null)
                        {
                            update.ServisKind  = comGroup.Text;
                            update.ServiceKala = txtKindKala.Text;
                            update.ServiseName = txtServiceName.Text;

                            if (txtServisPrice.Text != "")
                            {
                                update.ServicePrice = Convert.ToInt64(txtServisPrice.Text);
                            }
                            else
                            {
                                update.ServicePrice = 0;
                            }
                            context.SaveChanges();
                            context.Dispose();
                        }



                        lblError.ForeColor = Color.Green;
                        lblError.Text      = "ویرایش با موفقبت اتجام شد";
                        Refresh_Price();
                    }
                    else
                    {
                        lblError.ForeColor = Color.Red;
                        lblError.Text      = " خدمت با این مقادیر وجود دارد";
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new StimulsoftEntities())
                {
                    var delete = context.Manage.Where(current => current.UserName.Contains(txtUsername.Text)).ToList();
                    if (delete.Count == 0)
                    {
                        var result = MessageBox.Show("کاربر مورد نظر پیدا نشد،آیا همه موارد را میخواهید؟", "مدیریت", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (result == DialogResult.Yes)
                        {
                            dgManage.DataSource = context.Manage.ToList();
                            Refresh_Manage();
                        }
                        else
                        {
                            txtUsername.Focus();
                        }
                    }
                    if (delete.Count == 1)
                    {
                        Manage del = context.Manage.Where(current => current.UserName == txtUsername.Text).FirstOrDefault();
                        context.Manage.Remove(del);
                        context.SaveChanges();
                        lblError.ForeColor = Color.Green;
                        lblError.Text      = "کاربر با موفقیت حذف شد";
                        context.Dispose();



                        Refresh_Manage(); txtUsername.Text = ""; txtPassword.Text = ""; txtConfrimPasword.Text = "";
                    }
                    if (delete.Count > 1)
                    {
                        dgManage.DataSource = delete.ToList();
                    }
                }
            }
            catch (Exception)
            {
                lblError.ForeColor = Color.Red;
                lblError.Text      = "عملیات حذف با مشکل مواجه شد";
            }
        }
Exemplo n.º 4
0
        }// update kardane maghadire dgStore

        public void Add_Parent_Prodoct() // ezafe kardane faktore jadid be jadvale AnbarParent va tolide code rahgirie jadid
        {
            try
            {
                StimulsoftEntities context = new StimulsoftEntities();
                AnbarParent        parent  = new AnbarParent();
                parent.Case        = comCase.SelectedIndex;
                parent.Date        = int.Parse(Date.Text.Replace("/", ""));
                parent.Description = txtDetails.Text;
                context.AnbarParent.Add(parent);
                context.SaveChanges();
                //------
                groupProdoct.Enabled = true;
                dgProdoct.Focus();
                txtCodeProdoct.ForeColor = Color.Black;
                //-----
                if (context.Anbar.Count() > 0)
                {
                    var  listCodeRahgiri = context.Anbar.ToList();
                    long endCodeRahgiri  = Int32.Parse(listCodeRahgiri.LastOrDefault().CodeRahgiri.ToString());
                    endCodeRahgiri++;
                    lblCodeRahgiri.Text = endCodeRahgiri.ToString();
                }
                else if (context.Anbar.Count() == 0)
                {
                    lblCodeRahgiri.Text = "1";
                }
                context.Dispose();
                {
                    StimulsoftEntities context1 = new StimulsoftEntities();

                    if (context1.AnbarParent.Count() > 0)
                    {
                        var selectIdParent = context1.AnbarParent.ToList();

                        idParent = selectIdParent.LastOrDefault().Id;
                    }
                }
                //idParent = selectIdParent;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        private void btnAllUser_Click(object sender, EventArgs e)
        {
            try
            {
                dgSearch.DataSource = null;
                using (var context = new StimulsoftEntities())
                {
                    var AllUser = context.User.Where(c => c.Phone != null || c.Phone != "0").ToList();
                    dgSearch.DataSource = AllUser;

                    Design_GrideView_User();
                    lblUserCount.Text = dgSearch.RowCount.ToString();
                    context.Dispose();
                }
                txtMobilesNumbers.Text = Add_PhoneNumber_To_Text(dgSearch);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new StimulsoftEntities())
                {
                    if (txtUsername.Text != "")
                    {
                        var admin = context.Manage.Where(current => current.UserName == txtUsername.Text).ToList();
                        if (admin.Count == 1)
                        {
                            var update = context.Manage.Where(current => current.UserName == txtUsername.Text).FirstOrDefault();
                            if (update != null)
                            {
                                update.UserName = txtUsername.Text;
                                if (txtPassword.Text == txtConfrimPasword.Text)
                                {
                                    update.Password = txtPassword.Text;
                                    update.Access   = comAccess.SelectedIndex.ToString();
                                    //---
                                    if (chxNewService.Checked)
                                    {
                                        update.NewService = "1";
                                    }
                                    else
                                    {
                                        update.NewService = "0";
                                    }
                                    //---
                                    if (chxTools.Checked)
                                    {
                                        update.Tools = "1";
                                    }
                                    else
                                    {
                                        update.Tools = "0";
                                    }
                                    //---
                                    if (chxSearch.Checked)
                                    {
                                        update.Search = "1";
                                    }
                                    else
                                    {
                                        update.Search = "0";
                                    }
                                    //---
                                    if (chxSms.Checked)
                                    {
                                        update.Sms = "1";
                                    }
                                    else
                                    {
                                        update.Sms = "0";
                                    }
                                    //---
                                    if (chxReport.Checked)
                                    {
                                        update.Report = "1";
                                    }
                                    else
                                    {
                                        update.Report = "0";
                                    }
                                    //---
                                    if (chxBackup.Checked)
                                    {
                                        update.Backup = "1";
                                    }
                                    else
                                    {
                                        update.Backup = "0";
                                    }
                                    //---
                                    if (chxSetting.Checked)
                                    {
                                        update.Setting = "1";
                                    }
                                    else
                                    {
                                        update.Setting = "0";
                                    }

                                    context.SaveChanges();
                                    context.Dispose();
                                    lblError.ForeColor = Color.Green;
                                    lblError.Text      = "ویرایش با موفقبت اتجام شد";
                                    Refresh_Manage();
                                }
                                else
                                {
                                    lblError.ForeColor = Color.Red;
                                    lblError.Text      = "کلمه عبورها با هم یکسان نیست";
                                }
                            }
                            else
                            {
                                lblError.ForeColor = Color.Red; lblError.Text = "نام کاربر را وارد کنید";
                            }
                        }
                        else
                        {
                            lblError.ForeColor = Color.Red; lblError.Text = "کاربری با این نام وجود ندارد";
                        }
                    }
                    else
                    {
                        lblError.ForeColor = Color.Red; lblError.Text = "نام کاربر را وارد کنید";
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lbldel.Text == "1")
            {
                try
                {
                    lblError.Text = "";
                    try
                    {
                        using (var context = new StimulsoftEntities())
                        {
                            var delete = context.User.Where(current => current.Eshterak == txtEshterak.Text).ToList();
                            if (delete.Count == 0)
                            {
                                var result = MessageBox.Show("شماره اشتراک مورد نظر پیدا نشد،آیا همه موارد را میخواهید؟", "شماره اشتراک", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                if (result == DialogResult.Yes)
                                {
                                    dgDelete.DataSource = context.User.ToList();
                                    Refresh_dgUser();
                                }
                                else
                                {
                                    txtEshterak.Focus();
                                }
                            }
                            if (delete.Count == 1)
                            {
                                User del = context.User.Where(current => current.Eshterak == txtEshterak.Text).FirstOrDefault();
                                context.User.Remove(del);
                                context.SaveChanges();
                                lblError.ForeColor = Color.Green;
                                lblError.Text      = " اشتراک با موفقیت حذف شد";
                                context.Dispose();
                                Refresh_dgUser();

                                txtEshterak.Text = "";
                                txtEshterak.Focus();
                            }
                            if (delete.Count > 1)
                            {
                                dgDelete.DataSource = delete.ToList();
                            }
                        }
                    }
                    catch (Exception)
                    {
                        lblError.ForeColor = Color.Red;
                        lblError.Text      = "عملیات حذف با مشکل مواجه شد";
                        txtEshterak.Focus();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            //-----------------------
            //-----------------------
            if (lbldel.Text == "2")
            {
                try
                {
                    lblError.Text = "";
                    using (var context = new StimulsoftEntities())
                    {
                        string id     = dgDelete.CurrentRow.Cells[14].Value.ToString();
                        var    delete = context.Service.Where(current => current.IdService.ToString() == id).ToList();
                        if (delete.Count == 0)
                        {
                            var result = MessageBox.Show("شماره سرویس مورد نظر پیدا نشد،آیا همه موارد را میخواهید؟", "شماره سرویس", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (result == DialogResult.Yes)
                            {
                                dgDelete.DataSource = context.Service.ToList();
                                Refresh_dgService();
                            }
                            else
                            {
                                txtEshterak.Focus();
                            }
                        }
                        if (delete.Count == 1)
                        {
                            var del = context.Service.Where(current => current.IdService.ToString() == id).FirstOrDefault();
                            context.Service.Remove(del);
                            context.SaveChanges();
                            lblError.ForeColor = Color.Green;
                            lblError.Text      = " سرویس با موفقیت حذف شد";
                            Refresh_dgService();
                            context.Dispose();


                            txtEshterak.Text = "";
                            txtEshterak.Focus();
                        }
                        if (delete.Count > 1)
                        {
                            dgDelete.DataSource = delete.ToList();
                        }
                    }
                }
                catch (Exception)
                {
                    lblError.ForeColor = Color.Red;
                    lblError.Text      = "عملیات حذف با مشکل مواجه شد";
                    txtEshterak.Focus();
                }
            }
        }