Exemplo n.º 1
0
        private bool HardDelete(Purchase input)
        {
            try
            {
                if (input != null && input.Id > 0)
                {
                    var predicate = PredicateBuilder.True <PurchaseDetail>();
                    predicate = predicate.And(x => x.FK_PurchaseId == input.Id);

                    var saleDetails = _purchaseDetailOpp.GetAllUsingExpression(out int totalCount, 1, 0, predicate);

                    if (saleDetails != null)
                    {
                        foreach (var each in saleDetails)
                        {
                            if (each.Id > 0)
                            {
                                _purchaseDetailOpp.Delete(each.Id);
                            }
                        }
                    }
                    _purchaseOpp.Delete(input.Id);
                }
            }
            catch (Exception ex)
            {
                input.Msg       = "";
                input.IsFailure = true;
                throw ex;
            }
            return(true);
        }
Exemplo n.º 2
0
 static void TestCase(IOperation <int> obj)
 {
     obj.Merge(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     obj.Add(5);
     obj.Insert(4, 2);
     obj.Delete(1);
     obj.DeleteItem(4);
     obj.Sort();
     obj.Add(2);
     obj.Sort();
     obj.Search(5);
 }
Exemplo n.º 3
0
        public JsonResult DeletePost(int?Id)
        {
            try
            {
                NewsPost newstyp = newsPost.GetByID(x => x.Id == Id);
                if (newstyp != null)
                {
                    newsPost.Delete(x => x.Id == Id);
                    newsPost.Save();

                    Task.Factory.StartNew(() => new NewsOprations().UpdateData());
                    if (!string.IsNullOrEmpty(newstyp.HeaderImageName))
                    {
                        DeleteImage(newstyp.HeaderImageName);
                    }
                }
                try
                {
                    SchdulePostConfig schPostConfig = schulepostconfig.GetByID(x => x.PostId == Id);
                    if (schPostConfig != null)
                    {
                        schulepostconfig.Delete(x => x.PostId == Id);
                        schulepostconfig.Save();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
                return(Json(new { msg = "Post Deleted Successfully" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            return(Json(new { msg = "Post Deletion Unsucessful" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
 public JsonResult Delete(decimal Id)
 {
     try
     {
         tblcon.Delete(x => x.Id == Id);
         tblcon.Save();
         var result = new { Info = "Success", Formatting.None };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     return(null);
 }
Exemplo n.º 5
0
        private bool HardDelete(Sale input)
        {
            try
            {
                if (input != null && input.Id > 0)
                {
                    var predicate = PredicateBuilder.True <SaleDetail>();
                    predicate = predicate.And(x => x.FK_SaleId == input.Id);

                    var saleDetails = _saleDetailOpp.GetAllUsingExpression(out int totalCount, 1, 0, predicate);

                    if (saleDetails != null)
                    {
                        foreach (var each in saleDetails)
                        {
                            if (each.Id > 0)
                            {
                                _saleDetailOpp.Delete(each.Id);

                                //reversing available total amout
                                var product = _productOpp.GetUsingId(each.FK_ProductId);

                                Expression <Func <Product, object> >[] properties =
                                    new Expression <Func <Product, object> >[] { x => x.Availibility };

                                product.Availibility = product.Availibility + each.Quantity;
                                _productOpp.UpdateColumn(product, properties);
                            }
                        }
                    }
                    _saleOpp.Delete(input.Id);
                }
            }
            catch (Exception ex)
            {
                input.Msg       = "";
                input.IsFailure = true;
                throw ex;
            }
            return(true);
        }
Exemplo n.º 6
0
        public void Show(IOperation operation, IReadFile read, ICheckFile check, IDrowTable draw)
        {
            // operation.Employees = check.CheckFile(Log, read);
            operation.Employees = check.TickFile(Log, read);
            string alias;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("Введите команду: ");
                string command = Console.ReadLine();

                switch (command.ToLower())
                {
                case "add":

                    Console.Clear();

                    Console.WriteLine("Введите псевдоним сотрудника: ");
                    alias = Console.ReadLine();

                    if (alias.Length >= 15)
                    {
                        Console.WriteLine("Приносим извенения, но ваш псевдоним слишком длинный.");
                        Console.ReadKey();
                        continue;
                    }

                    //if (operation.Employees.Exists(x => x.Alias == alias))
                    //{

                    string name;
                    while (true)
                    {
                        Console.Clear();

                        Console.WriteLine("Введите имя сотрудника: ");
                        name = Console.ReadLine();
                        if (name.Length >= 16)
                        {
                            Console.WriteLine("Приносим извенения, но имя слишком длинное слишком длинное. Пожалуйста, используйте сокращенную форму имени.");
                            Console.ReadKey();
                        }
                        else
                        {
                            break;
                        }
                    }
                    string surname;
                    while (true)
                    {
                        Console.Clear();

                        Console.WriteLine("Введите фамилию сотрудника: ");
                        surname = Console.ReadLine();
                        if (surname.Length >= 18)
                        {
                            Console.WriteLine("Приносим извенения, но фамилия слишком длинное слишком длинное. Пожалуйста, используйте сокращенную форму фамилии.");
                            Console.ReadKey();
                        }
                        else
                        {
                            break;
                        }
                    }
                    string department;
                    while (true)
                    {
                        Console.Clear();

                        Console.WriteLine("Введите отдел сотрудника: ");
                        department = Console.ReadLine();
                        if (surname.Length >= 22)
                        {
                            Console.WriteLine("Некорректный ввод названия отдела.");
                            Console.ReadKey();
                        }
                        else
                        {
                            break;
                        }
                    }


                    string position;
                    while (true)
                    {
                        Console.Clear();

                        Console.WriteLine("Введите дожность сотрудника: ");
                        position = Console.ReadLine();
                        if (surname.Length >= 20)
                        {
                            Console.WriteLine("Некорректный наименования должности.");
                            Console.ReadKey();
                        }
                        else
                        {
                            break;
                        }
                    }
                    operation.NewEmp(alias, name, surname, department, position);
                    Console.WriteLine("Сотрудник успешно добавлен в базу данных.");

                    //}
                    //else
                    //{
                    //    Console.WriteLine("Сотрудник с такими паспортными данными уже существует!");
                    //}


                    Console.ReadKey();
                    break;

                case "delete":
                    while (true)
                    {
                        Console.Clear();
                        Console.WriteLine("Введите псевдоним сотрудника, которого вы хотите удалить");
                        alias = Console.ReadLine();
                        if (operation.Employees.Exists(x => x.Alias == alias))
                        {
                            operation.Delete(alias);
                            Console.WriteLine("Сотрудник был успешно удален с базы данных");
                            Console.ReadKey();
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Сотрудника с таким псевдонимом не найдено.");
                            Console.ReadKey();
                            break;
                        }
                    }
                    break;

                case "all":

                    Console.Clear();
                    Console.WriteLine(draw.MakeTableResults(operation.Employees));
                    Console.ReadKey();
                    break;

                case "find":

                    Console.Clear();
                    Console.WriteLine("Введите псевдоним сотрудника, которого вы хотите найти");
                    alias = Console.ReadLine();
                    if (operation.Employees.Exists(x => x.Alias == alias))
                    {
                        operation.Delete(alias);
                        Console.WriteLine(operation.FindEmployee(alias).ToString());
                        Console.ReadKey();
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Сотрудника с таким псевдонимом не найдено.");
                        Console.ReadKey();
                        break;
                    }

                case "exit":
                    if (read.ReadLine() == "XML")
                    {
                        Log = new LogXml();
                    }
                    if (read.ReadLine() == "BIN")
                    {
                        Log = new LogBinary();
                    }
                    Log.LogSave(operation.Employees);
                    return;
                }
                if (command.ToLower() != "add" && command.ToLower() != "delete" && command.ToLower() != "all" &&
                    command.ToLower() != "find" && command.ToLower() != "exit")
                {
                    Help();
                }
            }
        }
Exemplo n.º 7
0
 public ActionResult DeleteUser(Users _user)
 {
     useroper.Delete(_user.UserId);
     useroper.Save();
     return(View());
 }
Exemplo n.º 8
0
 public JsonResult DeleteLang(int Id)
 {
     useroper.Delete(Id);
     useroper.Save();
     return(Json(Id));
 }
        private void ControleOperation(bool save, bool modify = false)
        {
            try
            {
                if (save && modify == false)
                {
                    if (IsNotEmpty())
                    {
                        opt               = new Operation();
                        opt.Id            = Convert.ToInt32(TxtIdOperation.Text);
                        opt.DateOperation = Convert.ToDateTime(DtDateOperation.Text);
                        opt.Libelle       = TxtLibelleOperation.Text.Trim();
                        opt.Montant       = Convert.ToDouble(TxtMontant.Text);
                        opt.RefCompte1    = _idRefCompte1;
                        opt.Type1         = CmbType1.Text;
                        opt.RefCompte2    = _idRefCompte2;
                        opt.Type2         = CmbType2.Text;

                        opt.Save(opt);
                        ClearFields();
                    }
                }
                else if (save == false && modify == true)
                {
                    if (IsNotEmpty())
                    {
                        opt               = new Operation();
                        opt.Id            = Convert.ToInt32(TxtIdOperation.Text);
                        opt.DateOperation = Convert.ToDateTime(DtDateOperation.Text);
                        opt.Libelle       = TxtLibelleOperation.Text.Trim();
                        opt.Montant       = Convert.ToDouble(TxtMontant.Text);
                        opt.RefCompte1    = _idRefCompte1;
                        opt.Type1         = CmbType1.Text;
                        opt.RefCompte2    = _idRefCompte2;
                        opt.Type2         = CmbType2.Text;

                        opt.Update(opt);
                        ClearFields();
                    }
                }
                else if (save == false && modify == false)
                {
                    if (!string.IsNullOrEmpty(TxtIdOperation.Text))
                    {
                        opt               = new Operation();
                        opt.Id            = Convert.ToInt32(TxtIdOperation.Text);
                        opt.DateOperation = Convert.ToDateTime(DtDateOperation.Text);
                        opt.Libelle       = TxtLibelleOperation.Text.Trim();
                        opt.Montant       = Convert.ToDouble(TxtMontant.Text);
                        opt.RefCompte1    = _idRefCompte1;
                        opt.Type1         = CmbType1.Text;
                        opt.RefCompte2    = _idRefCompte2;
                        opt.Type2         = CmbType2.Text;

                        opt.Delete(opt.Id);
                        ClearFields();
                    }
                }

                LoadGridControle();
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (ImplementConnection.Instance.Conn != null)
                {
                    if (ImplementConnection.Instance.Conn.State == System.Data.ConnectionState.Open)
                    {
                        ImplementConnection.Instance.Conn.Close();
                    }
                }
            }
        }