Exemple #1
0
        public void chiaCaThoRuaXe()
        {
            DataTable table                   = this.nhanvienDAL.getNv_typeTho("Thợ Rửa");
            int       SoNV                    = this.nhanvienDAL.countEmployee_byType("Thợ Rửa");
            int       SoNVTrongCa             = 3;
            List <List <List <int> > > Result = XuLy(SoNV, SoNVTrongCa);
            //int dem = 0;
            int thu = 2;
            int ca  = 1;

            for (int i = 0; i < Result.Count; i++)               //thứ
            {
                for (int j = 0; j < Result[i].Count; j++)        //slca
                {
                    for (int k = 0; k < Result[i][j].Count; k++) //slnvtc
                    {
                        string            id_NV             = table.Rows[Result[i][j][k]]["ID CCCD"].ToString();
                        shift_ThoRuaXeDTO shift_ThoRuaXeDTO = dto(id_NV, thu, ca);
                        this.shift_ThoRuaXeDAL.insertShift(shift_ThoRuaXeDTO);
                    }
                    ca++;
                    if (ca == 4)
                    {
                        ca = 1;
                    }
                }
                thu++;
                if (thu == 9)
                {
                    thu = 2;
                }
            }
        }
Exemple #2
0
        private shift_ThoRuaXeDTO dto(string id_nv, int thu, int ca)
        {
            shift_ThoRuaXeDTO shift_ThoRuaXeDTO;

            if (thu == 2)
            {
                shift_ThoRuaXeDTO = new shift_ThoRuaXeDTO(id_nv, ca, 0, 0, 0, 0, 0, 0);
            }
            else if (thu == 3)
            {
                shift_ThoRuaXeDTO = new shift_ThoRuaXeDTO(id_nv, 0, ca, 0, 0, 0, 0, 0);
            }
            else if (thu == 4)
            {
                shift_ThoRuaXeDTO = new shift_ThoRuaXeDTO(id_nv, 0, 0, ca, 0, 0, 0, 0);
            }
            else if (thu == 5)
            {
                shift_ThoRuaXeDTO = new shift_ThoRuaXeDTO(id_nv, 0, 0, 0, ca, 0, 0, 0);
            }
            else if (thu == 6)
            {
                shift_ThoRuaXeDTO = new shift_ThoRuaXeDTO(id_nv, 0, 0, 0, 0, ca, 0, 0);
            }
            else if (thu == 7)
            {
                shift_ThoRuaXeDTO = new shift_ThoRuaXeDTO(id_nv, 0, 0, 0, 0, 0, ca, 0);
            }
            else
            {
                shift_ThoRuaXeDTO = new shift_ThoRuaXeDTO(id_nv, 0, 0, 0, 0, 0, 0, ca);
            }
            return(shift_ThoRuaXeDTO);
        }
Exemple #3
0
        public bool insertShift(shift_ThoRuaXeDTO shift)
        {
            try
            {
                this.openConnection();

                SqlCommand cmd = new SqlCommand("insert into SHIFT_ThoRuaXe_New (id_NV, Thu2, Thu3, Thu4, Thu5, Thu6, Thu7, ChuNhat) values (@id, @t2, @t3, @t4, @t5, @t6, @t7, @cn)", this.getConnection);
                cmd.Parameters.Add("@id", SqlDbType.NChar).Value = shift.id_NV;
                cmd.Parameters.Add("@t2", SqlDbType.Int).Value   = shift.Thu2;
                cmd.Parameters.Add("@t3", SqlDbType.Int).Value   = shift.Thu3;
                cmd.Parameters.Add("@t4", SqlDbType.Int).Value   = shift.Thu4;
                cmd.Parameters.Add("@t5", SqlDbType.Int).Value   = shift.Thu5;
                cmd.Parameters.Add("@t6", SqlDbType.Int).Value   = shift.Thu6;
                cmd.Parameters.Add("@t7", SqlDbType.Int).Value   = shift.Thu7;
                cmd.Parameters.Add("@cn", SqlDbType.Int).Value   = shift.ChuNhat;

                if (cmd.ExecuteNonQuery() == 1)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: ", ex.Message);
            }
            finally
            {
                this.closeConnection();
            }
            return(false);
        }