コード例 #1
0
        public int InsertIntoDepartment(DepartmentModel dept, UserModel currentUser)
        {
            MDBHelper = new MainDatabaseHelper();
            SqlCommand cmd = new SqlCommand("InsertDepartment");

            cmd.Parameters.AddWithValue("@DepartmentName", dept.DepartmentName);
            cmd.Parameters.AddWithValue("@CreatedBy", currentUser.UserID);
            cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
            cmd.Parameters.AddWithValue("@ModifiedBy", currentUser.UserID);
            cmd.Parameters.AddWithValue("@Modifiedate", DateTime.Now);
            cmd.Parameters.AddWithValue("@DeptBranch", dept.DeptBranch);
            cmd.Parameters.Add("@DepartmentID", SqlDbType.Int).Direction = ParameterDirection.Output;
            int departmentID = MDBHelper.RunQueryInDepartment(cmd);

            return(departmentID);
        }
コード例 #2
0
        //public static DepartmentCreateView Instance
        //{
        //    get
        //    {
        //        if (instance == null)
        //        {
        //            instance = new DepartmentCreateView();
        //        }
        //        return instance;
        //    }
        //}

        #endregion

        #region event or callback
        private void btnAdd_Click(object sender, EventArgs e)
        {
            dbHelper = new DatabaseHelper();
            DepartmentModel dept = new DepartmentModel();

            dept.DepartmentName = txtDepartmentName.Text;
            dept.CreatedBy      = _currentUser.UserID;
            dept.CreatedDate    = DateTime.Now;
            dept.ModifiedBy     = _currentUser.UserID;
            dept.ModifiedDate   = DateTime.Now;
            string        connectionString = @"Data Source=DESKTOP-AG0F2UT\NASIF;Initial Catalog=FInal_navy;Integrated Security=True";
            SqlConnection con          = new SqlConnection(connectionString);
            int           DepartmentID = dbHelper.InsertIntoDepartment(dept, _currentUser);

            MessageBox.Show("new Department Created.\nDepartment ID : " + DepartmentID, "Success", MessageBoxButtons.OK);
        }