Example #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                var      establishDate       = txtEstablishDate.Value.ToShortDateString();
                string   establishDateMiladi = null;
                DateTime d = ToMiladiDateString(establishDate);
                establishDateMiladi = d.ToString();
                if (ie.Configurations.Where(w => w.Name == "EstablishDate").Count() == 0)
                {
                    var q = new IE.Entities.Configuration();
                    q.Description = "EstablishDate";
                    q.Name        = "EstablishDate";
                    q.Value       = establishDateMiladi.ToString();
                    ie.Configurations.Add(q);
                    ie.SaveChanges();
                }
                else
                {
                    var q = ie.Configurations.Where(w => w.Name == "EstablishDate").Single();
                    q.Value = establishDateMiladi.ToString();
                    ie.SaveChanges();
                }

                if (ie.Configurations.Where(w => w.Name == "FiscalYear").Count() == 0)
                {
                    var q = new IE.Entities.Configuration();
                    q.Description = "FiscalYear";
                    q.Name        = "FiscalYear";
                    q.Value       = rddFiscalYear.SelectedValue.ToString();
                    ie.Configurations.Add(q);
                    ie.SaveChanges();
                }


                MessageBox.Show("با موفقیت به روز رسانی شد");
            }
            catch (Exception ex)
            {
                MessageBox.Show("خطایی رخ داد", "پیام سیستم", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void ReloadConfigurations()
        {
            if (ie.Configurations.Where(w => w.Name == "sgPath").Count() == 0)
            {
                var q = new IE.Entities.Configuration();
                q.Description = "sgPath";
                q.Name        = "sgPath";
                q.Value       = txtSgPath.Text;
                ie.Configurations.Add(q);
                ie.SaveChanges();
            }
            else
            {
                var q = ie.Configurations.Where(w => w.Name == "sgPath").Single();
                q.Value = txtSgPath.Text;
                ie.SaveChanges();
            }

            if (ie.Configurations.Where(w => w.Name == "UserName").Count() == 0)
            {
                var q = new IE.Entities.Configuration();
                q.Description = "UserName";
                q.Name        = "UserName";
                q.Value       = txtUserName.Text.ToString();
                ie.Configurations.Add(q);
                ie.SaveChanges();
            }
            else
            {
                var q = ie.Configurations.Where(w => w.Name == "UserName").Single();
                q.Value = txtUserName.Text.ToString();
                ie.SaveChanges();
            }

            if (ie.Configurations.Where(w => w.Name == "Branch").Count() == 0)
            {
                var q = new IE.Entities.Configuration();
                q.Description = "Branch";
                q.Name        = "Branch";
                q.Value       = rddBranches.SelectedValue.ToString();
                ie.Configurations.Add(q);
                ie.SaveChanges();
            }
            else
            {
                //var q = ie.Configurations.Where(w => w.Name == "Branch").Single();
                //q.Value = rddBranches.SelectedValue.ToString();
                //ie.SaveChanges();
            }


            if (ie.Configurations.Where(w => w.Name == "Ledger").Count() == 0)
            {
                var q = new IE.Entities.Configuration();
                q.Description = "Ledger";
                q.Name        = "Ledger";
                q.Value       = rddLedgers.SelectedValue.ToString();
                ie.Configurations.Add(q);
                ie.SaveChanges();
            }
            else
            {
                //var q = ie.Configurations.Where(w => w.Name == "Ledger").Single();
                //q.Value = rddLedgers.SelectedValue.ToString();
                //ie.SaveChanges();
            }

            if (ie.Configurations.Where(w => w.Name == "Password").Count() == 0)
            {
                var q = new IE.Entities.Configuration();
                q.Description = "Password";
                q.Name        = "Password";
                q.Value       = txtPassword.Text.ToString();
                ie.Configurations.Add(q);
                ie.SaveChanges();
            }
            else
            {
                var q = ie.Configurations.Where(w => w.Name == "Password").Single();
                q.Value = q.Value = txtPassword.Text.ToString();
                ie.SaveChanges();
            }
        }