Ejemplo n.º 1
0
        private void btnDeleteMotorOil_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new kitchenEntities())
                {
                    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      = "عملیات حذف با مشکل مواجه شد";
            }
        }
Ejemplo n.º 2
0
        private void btnUpdatePriceOilMotor_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new kitchenEntities())
                {
                    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);
            }
        }
Ejemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new kitchenEntities())
                {
                    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      = "عملیات حذف با مشکل مواجه شد";
            }
        }
Ejemplo n.º 4
0
        private void btnAllUser_Click(object sender, EventArgs e)
        {
            try
            {
                dgSearch.DataSource = null;
                using (var context = new kitchenEntities())
                {
                    var AllUser = context.User.Where(c => c.Phone != null).ToList();
                    dgSearch.DataSource = AllUser;

                    Design_GrideView_User();

                    context.Dispose();
                }


                //---
                txtMobilesNumbers.Text = "";
                int r   = 0;
                int end = dgSearch.RowCount;

                while (r < end)
                {
                    string mobile;
                    mobile = dgSearch.Rows[r].Cells[3].Value.ToString();
                    if (mobile != "" && mobile != null && mobile.Length == 11 && mobile != "0")
                    {
                        txtMobilesNumbers.Text += mobile + ".";
                        r++;
                    }
                    else
                    {
                        r++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 5
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            try
            {
                using (var context = new kitchenEntities())
                {
                    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);
            }
        }
Ejemplo n.º 6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lbldel.Text == "1")
            {
                try
                {
                    lblError.Text = "";
                    try
                    {
                        using (var context = new kitchenEntities())
                        {
                            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 kitchenEntities())
                    {
                        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();
                }
            }
        }