Exemple #1
0
        public CompanyDO UpdateCompany(CompanyDO company)
        {
            var original = _companyDao.ReadCompanyById(company.CompanyId);

            company.SubscriptionReference = original.SubscriptionReference;
            return(_companyDao.Update(company));
        }
Exemple #2
0
        /// <summary>
        /// Selects Company records by PK
        /// </summary>
        public static CompanyDO[] GetByPK(Int32 CompanyId)
        {
            SqlParameter _CompanyId = new SqlParameter("CompanyId", SqlDbType.Int);

            _CompanyId.Value = CompanyId;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyId
            };

            string pid = ConfigurationManager.AppSettings["PID"];

            SafeReader sr = DataCommon.ExecuteSafeReader(String.Format("[{0}].[Company_GetByPK]", pid), _params, pid);


            List <CompanyDO> objs = new List <CompanyDO>();

            while (sr.Read())
            {
                CompanyDO obj = new CompanyDO();

                obj.CompanyId   = sr.GetInt32(sr.GetOrdinal("CompanyId"));
                obj.Name        = sr.GetString(sr.GetOrdinal("Name"));
                obj.PhoneNumber = sr.GetString(sr.GetOrdinal("PhoneNumber"));


                objs.Add(obj);
            }

            return(objs.ToArray());
        }
        private void btnAccept_Click(object sender, EventArgs e)
        {
            string    Name              = txtCompanyName.Text;
            string    Address           = txtAddress.Text;
            string    District          = txtDistrict.Text;
            string    City              = txtCity.Text;
            string    Country           = txtCountry.Text;
            string    TaxCode           = txtTaxCode.Text;
            string    BankName          = txtBankName.Text;
            string    BankAccount       = txtBankAccount.Text;
            string    Tel               = txtTel.Text;
            string    Fax               = txtFax.Text;
            string    Email             = txtEmail.Text;
            string    Website           = txtWeb.Text;
            DateTime  FoundedDay        = dtFoundedDay.Value;
            string    Note              = txtNote.Text;
            string    companycode       = txtCompanyCode.Text;
            string    healthInsuranceID = txtHealthInsuranceID.Text;
            CompanyDO companyDO         = new CompanyDO();
            int       result            = 0;

            try
            {
                result = companyDO.UpdateDefaultCompanyInfo(Name, Address, City, Country, Tel, Fax, Email, District, Website, TaxCode, BankName, BankAccount, FoundedDay, Note, healthInsuranceID, companycode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi cập nhật CSDL !", "Thông báo");
            }
            if (result == 1)
            {
                MessageBox.Show("Cập nhật thành công !", "Thông báo");
            }
            this.Close();
        }
        //private SystemDataConnect Sysconnect = new SystemDataConnect();
        private void frmCompanyUserInfo_Load(object sender, EventArgs e)
        {
            CompanyDO companyDO = new CompanyDO();
            DataSet   dsCompany = companyDO.GetCompanyInfo();

            if (dsCompany.Tables[0].Rows.Count == 0)
            {
                return;
            }
            DataRow row = dsCompany.Tables[0].Rows[0];

            txtCompanyName.Text       = row["Name"].ToString();
            txtAddress.Text           = row["Address"].ToString();
            txtDistrict.Text          = row["District"].ToString();
            txtCity.Text              = row["City"].ToString();
            txtCountry.Text           = row["Country"].ToString();
            txtTaxCode.Text           = row["TaxCode"].ToString();
            txtBankAccount.Text       = row["BankAccount"].ToString();
            txtBankName.Text          = row["BankName"].ToString();
            txtTel.Text               = row["Tel"].ToString();
            txtFax.Text               = row["Fax"].ToString();
            txtEmail.Text             = row["Email"].ToString();
            txtWeb.Text               = row["Website"].ToString();
            dtFoundedDay.Value        = DateTime.Parse(row["FoundedDay"].ToString());
            txtNote.Text              = row["Note"].ToString();
            txtCompanyCode.Text       = row["CompanyCode"].ToString();
            txtHealthInsuranceID.Text = row["HealthInsuranceID"].ToString();
        }
Exemple #5
0
        /// <summary>
        /// Deletes a Company record
        /// </summary>
        public int Delete(CompanyDO DO, DalapiTransaction Transaction)
        {
            SqlParameter _CompanyId = new SqlParameter("CompanyId", SqlDbType.Int);

            _CompanyId.Value = DO.CompanyId;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyId
            };


            return(DataCommon.ExecuteScalar(String.Format("[{0}].[Company_Delete]", pid), _params, pid, Transaction));
        }
Exemple #6
0
        /// <summary>
        /// Deletes a Company record
        /// </summary>
        public static int Delete(CompanyDO DO, DalapiTransaction Transaction)
        {
            SqlParameter _CompanyId = new SqlParameter("CompanyId", SqlDbType.Int);

            _CompanyId.Value = DO.CompanyId;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyId
            };

            string pid = ConfigurationManager.AppSettings["PID"];

            return(DataCommon.ExecuteScalar(String.Format("[{0}].[Company_Delete]", pid), _params, pid, Transaction));
        }
Exemple #7
0
        /// <summary>
        /// Creates a new Company record
        /// </summary>
        public int Create(CompanyDO DO, DalapiTransaction Transaction)
        {
            SqlParameter _Name        = new SqlParameter("Name", SqlDbType.VarChar);
            SqlParameter _PhoneNumber = new SqlParameter("PhoneNumber", SqlDbType.VarChar);

            _Name.Value        = DO.Name;
            _PhoneNumber.Value = DO.PhoneNumber;

            SqlParameter[] _params = new SqlParameter[] {
                _Name,
                _PhoneNumber
            };


            return(DataCommon.ExecuteScalar(String.Format("[{0}].[Company_Insert]", pid), _params, pid, Transaction));
        }
Exemple #8
0
        /// <summary>
        /// Updates a Company record and returns the number of records affected
        /// </summary>
        public static int Update(CompanyDO DO, DalapiTransaction Transaction)
        {
            SqlParameter _CompanyId   = new SqlParameter("CompanyId", SqlDbType.Int);
            SqlParameter _Name        = new SqlParameter("Name", SqlDbType.VarChar);
            SqlParameter _PhoneNumber = new SqlParameter("PhoneNumber", SqlDbType.VarChar);

            _CompanyId.Value   = DO.CompanyId;
            _Name.Value        = DO.Name;
            _PhoneNumber.Value = DO.PhoneNumber;

            SqlParameter[] _params = new SqlParameter[] {
                _CompanyId,
                _Name,
                _PhoneNumber
            };

            string pid = ConfigurationManager.AppSettings["PID"];

            return(DataCommon.ExecuteScalar(String.Format("[{0}].[Company_Update]", pid), _params, pid, Transaction));
        }
Exemple #9
0
        /// <summary>
        /// Gets all Company records
        /// </summary>
        public CompanyDO[] GetAll()
        {
            SafeReader sr = DataCommon.ExecuteSafeReader(String.Format("[{0}].[Company_GetAll]", pid), new SqlParameter[] { }, pid);

            List <CompanyDO> objs = new List <CompanyDO>();

            while (sr.Read())
            {
                CompanyDO obj = new CompanyDO();

                obj.CompanyId   = sr.GetInt32(sr.GetOrdinal("CompanyId"));
                obj.Name        = sr.GetString(sr.GetOrdinal("Name"));
                obj.PhoneNumber = sr.GetString(sr.GetOrdinal("PhoneNumber"));



                objs.Add(obj);
            }

            return(objs.ToArray());
        }
        public UserDO CreateSubscription(Subscription subscription, string originalEmail)
        {
            //create Subscription
            var subscriptionDo = _mapper.Map <SubscriptionDO>(subscription);

            subscriptionDo.OriginalEmail = originalEmail;
            _log.InfoFormat("Subscription ID:{0}, subscription created in DB. {1}", subscription.SubscriptionReference,
                            subscriptionDo);

            //create Company
            var company = new CompanyDO();

            if (string.IsNullOrEmpty(subscription.Customer.Company))
            {
                company.Name = $"{subscription.Customer.FirstName} {subscription.Customer.LastName}";
            }
            else
            {
                company.Name = subscription.Customer.Company;
            }
            company.SubscriptionReference = subscriptionDo.SubscriptionReference;
            company.Subscription          = subscriptionDo;
            _companyDao.Create(company);
            _log.InfoFormat("Subscription ID:{0}, company created in DB. {1}", subscription.SubscriptionReference,
                            company);

            //create master User
            var user = new UserDO();

            user.EMail            = subscription.Customer.Email;
            user.FirstName        = subscription.Customer.FirstName;
            user.FamilyName       = subscription.Customer.LastName;
            user.PhoneNumber      = subscription.Customer.PhoneNumber;
            user.IsCompanyAdmin   = true;
            user.CompanyId        = company.CompanyId;
            user.IsPinzSuperAdmin = false;
            user.Password         = RandomPassword.Generate();
            user = _userDao.Create(user);
            _log.InfoFormat("Subscription ID:{0}, user created in DB. {1}", subscription.SubscriptionReference, user);

            //create Project
            var project = new ProjectDO
            {
                CompanyId   = company.CompanyId,
                Name        = "GetStarted",
                Description = "Project to get you started with PINZ! Feel free to rename and use as you like."
            };

            project = _projectDao.Create(project);

            //staff user as admin on project
            var ps = new ProjectStaffDO
            {
                ProjectId      = project.ProjectId,
                UserId         = user.UserId,
                IsProjectAdmin = true
            };

            _projectStaffDao.Create(ps);

            //create tasks
            var categoryAdministration = CreateCategory(project, "Administration");

            CreateTask(categoryAdministration, user, "Rename this project",
                       "In the Outlook Ribbon, click on PINZ tab. Fromo there you can navigate to Administration panel.");

            CreateTask(categoryAdministration, user, "Invite more users",
                       "In the Outlook Ribbon, click on PINZ tab. Fromo there you can navigate to Administration panel.");

            CreateTask(categoryAdministration, user, "Close Tasks",
                       "Close Tasks by ticking the checkboxes in the task list.");

            CreateTask(categoryAdministration, user, "Delete Categories",
                       "Only empty categories can be deleted.");

            var educationAdministration = CreateCategory(project, "Education");

            CreateTask(educationAdministration, user, "Visit Support Page",
                       "Visit our Support Senter at https://pinzonline.zendesk.com for more information.");

            return(user);
        }
Exemple #11
0
 /// <summary>
 /// Deletes a Company record
 /// </summary>
 public static int Delete(CompanyDO DO)
 {
     return(Delete(DO, null));
 }
Exemple #12
0
 /// <summary>
 /// Updates a Company record and returns the number of records affected
 /// </summary>
 public static int Update(CompanyDO DO)
 {
     return(Update(DO, null));
 }
Exemple #13
0
 /// <summary>
 /// Creates a new Company record
 /// </summary>
 public static int Create(CompanyDO DO)
 {
     return(Create(null));
 }
Exemple #14
0
 public void DeleteCompany(CompanyDO company)
 {
     _companyDao.Delete(company);
 }
Exemple #15
0
 public CompanyDO CreateCompany(CompanyDO company)
 {
     return(_companyDao.Create(company));
 }