コード例 #1
0
 public void Delete(AccountingMoeinDetail moi)
 {
     try
     {
         Table.Remove(moi);
         this.SubmitChanges();
     }
     catch
     {
         throw;
     }
 }
コード例 #2
0
 public void Save(AccountingMoeinDetail entity)
 {
     try
     {
         this.Save(new List <Data.AccountingMoeinDetail>()
         {
             entity
         });
     }
     catch
     {
         throw;
     }
 }
コード例 #3
0
 private void PrepareMoein(AccountingMoeinDetail item)
 {
     try
     {
         item.MDName   = txt_moien.Text;
         item.MDNameEn = txt_name_latin_moien.Text;
         item.IdIn     = txt_moien_code.Text;
         var view = Business.GetAccountingMoeinDetailBusiness().GetViewById(item.Id);
         if (view == null || view.IdIn != item.IdIn)
         {
             item.LastEdit = DateTime.Now;
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #4
0
        private Data.AccountingMoeinDetail SaveGroup()
        {
            try
            {
                var    accountingMoeinDetailBusiness = Business.GetAccountingMoeinDetailBusiness();
                var    groups       = new List <Data.AccountingMoeinDetail>();
                var    group        = new Data.AccountingMoeinDetail();
                string oldGroupIdIn = null;
                //edit mode
                group = accountingMoeinDetailBusiness.GetByAccountingMoeinDetailId(AccountingMoeinId, Common.Constants.CodeTitle.Goruh).FirstOrDefault();
                if (group == null)
                {
                    group = new AccountingMoeinDetail()
                    {
                        IdAccountingMoein = AccountingMoeinId, IdCodeTitle = Common.Constants.CodeTitle.Goruh
                    }
                }
                ;
                else
                {
                    oldGroupIdIn = group.IdIn;
                }
                PrepareGroup(group);
                groups.Add(group);

                if (oldGroupIdIn != null)
                {
                    var otherGroups = accountingMoeinDetailBusiness.GetByIdIn(oldGroupIdIn, Common.Constants.CodeTitle.Goruh).Where(r => r.IdAccountingMoein != AccountingMoeinId).ToList();
                    otherGroups.ForEach(r => PrepareGroup(r));
                    groups.AddRange(otherGroups);
                }

                accountingMoeinDetailBusiness.Save(groups);
                return(group);
            }
            catch
            {
                throw;
            }
        }
コード例 #5
0
        /// <summary>
        /// ثبت اطلاعات در جدول accountingMoien
        /// </summary>
        /// <param name="accountingMoienId"></param>
        /// <param name="grouhIdIn"></param>
        /// <param name="kolIdIn"></param>
        /// <param name="moienIdIn"></param>
        /// <param name="moienName"></param>



        /// <summary>
        ///بررسی جدول و پاک کردن رکورد در صورت تکراری بودن
        /// </summary>
        /// <param name="C_id_accounting_moien">کد معین ثبت شده</param>
        /// <param name="IdInGrouh">accountig moien گروه ثبت شده</param>
        /// <param name="IdInKol">accountig moien کل ثبت شده</param>
        /// <param name="IdInMoien">accountig moien معین ثبت شده</param>
        /// <returns></returns>
        private bool check_for_duplication_record(string C_id_accounting_moien, string IdInGrouh, string IdInKol, string IdInMoien)
        {
            int counter = 0;

            string[] sorted_idn = new string[3];


            List <AccountingMoeinDetail> get_all_from_table = ak1.AccountingMoeinDetails.OrderBy(i => i.IdAccountingMoein).ToList();

            ///////////////////////////////////////////////////////////////////////
            for (int i = 0; i <= get_all_from_table.Count - 1; i += 3)
            {
                for (int j = i; j <= (i + 3) - 1; j++)
                {
                    if (get_all_from_table[j].IdCodeTitle == Common.Constants.CodeTitle.Goruh)
                    {
                        sorted_idn[0] = get_all_from_table[j].IdIn.ToString();
                    }

                    if (get_all_from_table[j].IdCodeTitle == Common.Constants.CodeTitle.Kol)
                    {
                        sorted_idn[1] = get_all_from_table[j].IdIn.ToString();
                    }

                    if (get_all_from_table[j].IdCodeTitle == Common.Constants.CodeTitle.Moein)
                    {
                        sorted_idn[2] = get_all_from_table[j].IdIn.ToString();
                    }
                }
                ////////////////////////////////////////////////////////////////////

                if (sorted_idn[0] == IdInGrouh && sorted_idn[1] == IdInKol && sorted_idn[2] == IdInMoien)
                {
                    counter++;
                }

                if (sorted_idn[0] == "")
                {
                    counter = 2;
                }
            }


            if (counter > 1)
            {
                /////// پاک کردن تمام رکوردهای ثبت شده

                Guid guid_id_moien        = Guid.Parse(C_id_accounting_moien);
                AccountingMoeinDetail akm = ak1.AccountingMoeinDetails.First(i => i.IdAccountingMoein == guid_id_moien);
                ak1.AccountingMoeinDetails.Remove(akm);
                ak1.SaveChanges();

                AccountingMoeinDetail akm1 = ak1.AccountingMoeinDetails.First(i => i.IdAccountingMoein == guid_id_moien);
                ak1.AccountingMoeinDetails.Remove(akm1);
                ak1.SaveChanges();

                AccountingMoeinDetail akm2 = ak1.AccountingMoeinDetails.First(i => i.IdAccountingMoein == guid_id_moien);
                ak1.AccountingMoeinDetails.Remove(akm2);
                ak1.SaveChanges();

                return(true);
            }


            return(false);
        }