Пример #1
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            if (BaseValidator.IsFormValid(this.components))
            {
                if (RbtnIncome.Checked || RbtnOutgoing.Checked)
                {
                    db = new UnitofWork();
                    DataLayer.Accounting accounting = new DataLayer.Accounting()
                    {
                        Amount      = int.Parse(NumericAmount.Value.ToString()),
                        TypeID      = (RbtnIncome.Checked) ? 1 : 2,
                        CustomerID  = db.CustomerRepository.GetCustomerIdByName(TxtName.Text),
                        Description = TxtDecription.Text,
                        Datetime    = DateTime.Now
                    };
                    if (AccountId == 0)
                    {
                        db.accountingrepository.Insert(accounting);
                    }
                    else
                    {
                        accounting.AccID = AccountId;
                        db.accountingrepository.Update(accounting);
                    }

                    db.Save();
                    db.Dispose();
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    RtlMessageBox.Show("لطفا نوع تراکنش را انتخاب کنید");
                }
            }
        }
Пример #2
0
 private void TxtFilter_TextChanged(object sender, EventArgs e)
 {
     db = new UnitofWork();
     MydataGridView.AutoGenerateColumns = false;
     MydataGridView.DataSource          = db.CustomerRepository.GetCustomersName(TxtFilter.Text);
     db.Dispose();
 }
Пример #3
0
        static void Main(string[] args)
        {
            UnitofWork db = new UnitofWork();

            var list = db.CustomerRepository.GetAllCustomers();

            db.Dispose();
        }
Пример #4
0
 public bool Login(string username, string password)
 {
     using (var unitofwork = new UnitofWork(new JooleEntities())) {
         List <User> tempuser = unitofwork.UserRepository.Get(
             filter: u => u.UserName == username
             ).ToList();
         if (tempuser.Count != 0)
         {
             unitofwork.Dispose();
             string temppassword = tempuser[0].Password;
             if (temppassword == password)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             tempuser = unitofwork.UserRepository.Get(
                 filter: u => u.Email == username
                 ).ToList();
             if (tempuser.Count == 0)
             {
                 return(false);
             }
             unitofwork.Dispose();
             string temppassword = tempuser[0].Password;
             if (temppassword == password)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
 }
Пример #5
0
 private void Transaction_Load(object sender, EventArgs e)
 {
     db = new UnitofWork();
     MydataGridView.AutoGenerateColumns = false;
     MydataGridView.DataSource          = db.CustomerRepository.GetCustomersName();
     if (AccountId != 0)
     {
         var Account = db.accountingrepository.GetById(AccountId);
         NumericAmount.Value = Convert.ToDecimal(Account.Amount.ToString());
         TxtDecription.Text  = Account.Description;
         TxtName.Text        = db.CustomerRepository.GetCustomerNameById(Account.CustomerID);
         if (Account.TypeID == 1)
         {
             RbtnIncome.Checked = true;
         }
         else
         {
             RbtnOutgoing.Checked = true;
         }
         this.Text      = "ویرایش";
         BtnSubmit.Text = "ویرایش";
     }
     db.Dispose();
 }