Beispiel #1
0
        /// <summary>
        /// 新增员工
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId">操作员工编码</param>
        /// <param name="strOpStaffName">操作员工姓名</param>
        /// <param name="strErrText">出错信息</param>
        /// <returns>成功返回True,否则返回False</returns>
        public long InsertStaff(Staff data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            long nStaffId = 0;

            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StaffDAO dao = new StaffDAO())
                    {
                        nStaffId = dao.InsertStaff(data, nOpStaffId, strOpStaffName, out strErrText);
                        if (nStaffId <= 0)
                        {
                            return(0);
                        }
                    }
                    transScope.Complete();
                }
                return(nStaffId);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(0);
            }
        }
Beispiel #2
0
 //Thêm Staff
 void AddStaff(string id, string hoTen, DateTime ngaySinh, string diaChi, string sdt, int cmnd)
 {
     if (StaffDAO.InsertStaff(id, hoTen, ngaySinh, diaChi, sdt, cmnd))
     {
         MessageBox.Show("Thêm nhân viên thành công");
     }
     else
     {
         MessageBox.Show("Thêm nhân viên thất bại");
     }
 }