public int AddGioLamViec(GioLamViec glv)
 {
     try
     {
         return(new Congnhan().AddGioLamViec(glv));
     }
     catch (Exception p)
     {
         throw p;
     }
 }
 public int UpdateGioLamViec1(GioLamViec glv)
 {
     try
     {
         return(new Congnhan().UpdateGioLamViec1(glv));
     }
     catch (Exception p)
     {
         throw p;
     }
 }
示例#3
0
文件: Congnhan.cs 项目: leson96/Demo
        public int UpdateGioLamViec1(GioLamViec glv)
        {
            List <SqlParameter> paras = new List <SqlParameter>();

            paras.Add(new SqlParameter("@macalamviec", glv.MaCaLV));
            paras.Add(new SqlParameter("@giotoi", glv.GioToi));
            paras.Add(new SqlParameter("@thu", glv.Thu));
            paras.Add(new SqlParameter("@giove", glv.GioToi));
            paras.Add(new SqlParameter("@ditre", glv.DiTre));
            paras.Add(new SqlParameter("@ngaythangnam", glv.NgayThangNam));
            paras.Add(new SqlParameter("@macn", glv.MaCN));
            paras.Add(new SqlParameter("@magiolamviec", glv.MaGioLamViec));
            try
            {
                return(p.ExecNonQuery("", CommandType.StoredProcedure, paras));
            }
            catch (SqlException p)
            {
                throw p;
            }
        }
示例#4
0
文件: Congnhan.cs 项目: leson96/Demo
 public List <GioLamViec> ViewGioLamViec(string sql)
 {
     try
     {
         List <GioLamViec> list = new List <GioLamViec>();
         SqlDataReader     dr   = p.View(sql);
         if (dr != null)
         {
             string   MaCaLV, Thu, MaCN, MaGioLamViec, Ho, Ten, Hinh;
             TimeSpan GioToi, GioVe;
             DateTime NgayThangNam;
             bool     DiTre;
             TimeSpan Tong;
             while (dr.Read())
             {
                 MaCaLV       = dr.GetString(0);
                 Thu          = dr.GetString(1);
                 GioToi       = dr.GetTimeSpan(2);
                 GioVe        = dr.GetTimeSpan(3);
                 DiTre        = dr.GetBoolean(4);
                 Tong         = dr.GetTimeSpan(5);
                 NgayThangNam = dr.GetDateTime(6);
                 MaCN         = dr.GetString(7);
                 MaGioLamViec = dr.GetString(8);
                 Ho           = dr.GetString(9);
                 Ten          = dr.GetString(10);
                 Hinh         = dr.GetString(11);
                 GioLamViec glv = new GioLamViec(MaCaLV, Thu, GioToi, GioVe, DiTre, Tong, NgayThangNam, MaCN, MaGioLamViec, Ho, Ten, Hinh);
                 list.Add(glv);
             }
         }
         return(list);
     }
     catch (SqlException p)
     {
         throw p;
     }
 }
        private void btCheckin_Click(object sender, EventArgs e)
        {
            if (txtMaCN_tkCC.Text == "")
            {
                MessageBox.Show("Không có dữ liệu để checkin", "Thông báo");
                return;
            }
            string   day    = DateTime.Now.DayOfWeek.ToString();
            TimeSpan giotoi = DateTime.Now.TimeOfDay;

            if (giotoi.Hours <= 11)
            {
                bool ditre = false;
                if (giotoi.Hours > 7)
                {
                    ditre = true;
                }
                GioLamViec glv = new GioLamViec("CALV1", day, giotoi, new TimeSpan(0, 0, 0), ditre, new TimeSpan(0), DateTime.Now, txtMaCN_tkCC.Text, txtMaCN_tkCC.Text);
                try
                {
                    cnb.AddGioLamViec(glv);
                }
                catch (Exception p)
                {
                    MessageBox.Show(p.ToString());
                }
            }
            if (giotoi.Hours >= 11 && giotoi.Hours <= 18)
            {
                bool ditre = false;
                if (giotoi.Hours > 11)
                {
                    ditre = true;
                }
                GioLamViec glv = new GioLamViec("CALV2", day, giotoi, new TimeSpan(0, 0, 0), ditre, new TimeSpan(0), DateTime.Now, txtMaCN_tkCC.Text, txtMaCN_tkCC.Text);
                try
                {
                    cnb.AddGioLamViec(glv);
                }
                catch (Exception p)
                {
                    MessageBox.Show(p.ToString());
                }
            }
            if (giotoi.Hours > 18)
            {
                bool ditre = false;
                if (giotoi.Hours > 18)
                {
                    ditre = true;
                }
                GioLamViec glv = new GioLamViec("CALV3", day, giotoi, new TimeSpan(0, 0, 0), ditre, new TimeSpan(0), DateTime.Now, txtMaCN_tkCC.Text, txtMaCN_tkCC.Text);
                try
                {
                    cnb.AddGioLamViec(glv);
                }
                catch (Exception p)
                {
                    MessageBox.Show(p.ToString());
                }
            }
            try
            {
                dgvCheck.DataSource = cnb.ViewGioLamViec("SELECT MaCaLV,Thu,GioToi,GioVe,DiTre,Tong,[Ngay/Thang/Nam],GioLamViec.MaNV,MaGioLamViec,Ho,Ten,Hinh FROM GioLamViec,CongNhan WHERE GioLamViec.MaNV=CongNhan.MaNV AND Thu='" + day + "'").ToList();
                cnb.AddLich(txtMaCN_CC.Text, DateTime.Now);
            }
            catch (Exception p)
            {
                MessageBox.Show(p.ToString());
            }
        }