public Resource Resource_insert()
 {
     Resource.Resource_Type_ID = Convert.ToInt32(Insert_Resource_Type_ID_txt.Text);
     Resource.Description      = Insert_Description_txt.Text;
     Resource.Address          = Insert_Address_txt.Text;
     Resource.City             = Insert_City_txt.Text;
     Resource.State            = Insert_State_txt.Text;
     Resource.Zip Code = Insert_Zip Code_txt.Text;
     Resource.PayType           = Insert_PayType_txt.Text;
     Resource.PayRate           = Convert.ToDecimal(Insert_PayRate_txt.Text);
     Resource.AvailabilityDate  = Convert.ToDateTime(Insert_AvailabilityDate_txt.Text);
     Resource.AvailabilityHours = Convert.ToDateTime(Insert_AvailabilityHours_txt.Text);
     Resource = Resource.Insert(Resource);
     Insert_Resource_GridView.DataBind();
     Update_Resource_GridView.DataBind();
     Delete_Resource_GridView.DataBind();
     return(Resource);
 }
 public Resource Resource_update(int ID)
 {
     Resource                  = Resource.Select(ID);
     Resource.Resource_ID      = Convert.ToInt32(Update_Resource_ID_txt.Text);
     Resource.Resource_Type_ID = Convert.ToInt32(Update_Resource_Type_ID_txt.Text);
     Resource.Description      = Update_Description_txt.Text;
     Resource.Address          = Update_Address_txt.Text;
     Resource.City             = Update_City_txt.Text;
     Resource.State            = Update_State_txt.Text;
     Resource.Zip Code = Update_Zip Code_txt.Text;
     Resource.PayType           = Update_PayType_txt.Text;
     Resource.PayRate           = Convert.ToDecimal(Update_PayRate_txt.Text);
     Resource.AvailabilityDate  = Convert.ToDateTime(Update_AvailabilityDate_txt.Text);
     Resource.AvailabilityHours = Convert.ToDateTime(Update_AvailabilityHours_txt.Text);
     Resource.Update(Resource);
     Insert_Resource_GridView.DataBind();
     Update_Resource_GridView.DataBind();
     Delete_Resource_GridView.DataBind();
     return(Resource);
 }
Beispiel #3
0
        public Resource Select(int id)
        {
            Resource      Resource         = new Resource();
            string        ConnectionString = IDManager.connection();
            SqlConnection con = new SqlConnection(ConnectionString);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_RESOURCE", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Resource_ID", id);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    rdr.Read();
                    if (!rdr.IsDBNull(0))
                    {
                        Resource.Resource_ID = rdr.GetInt32(0);
                    }
                    else
                    {
                        Resource.Resource_ID = 0;
                    }
                    if (!rdr.IsDBNull(1))
                    {
                        Resource.Resource_Type_ID = rdr.GetInt32(1);
                    }
                    else
                    {
                        Resource.Resource_Type_ID = 0;
                    }
                    if (!rdr.IsDBNull(2))
                    {
                        Resource.Description = rdr.GetString(2);
                    }
                    else
                    {
                        Resource.Description = " ";
                    }
                    if (!rdr.IsDBNull(3))
                    {
                        Resource.Address = rdr.GetString(3);
                    }
                    else
                    {
                        Resource.Address = " ";
                    }
                    if (!rdr.IsDBNull(4))
                    {
                        Resource.City = rdr.GetString(4);
                    }
                    else
                    {
                        Resource.City = " ";
                    }
                    if (!rdr.IsDBNull(5))
                    {
                        Resource.State = rdr.GetString(5);
                    }
                    else
                    {
                        Resource.State = " ";
                    }
                    if (!rdr.IsDBNull(6))
                    {
                        Resource.Zip Code = rdr.GetString(6);
                    }
                    else
                    {
                        Resource.Zip Code = " ";
                    }
                    if (!rdr.IsDBNull(7))
                    {
                        Resource.PayType = rdr.GetString(7);
                    }
                    else
                    {
                        Resource.PayType = " ";
                    }
                    if (!rdr.IsDBNull(8))
                    {
                        Resource.PayRate = rdr.GetDecimal(8);
                    }
                    else
                    {
                        Resource.PayRate = 0;
                    }
                    if (!rdr.IsDBNull(9))
                    {
                        Resource.AvailabilityDate = rdr.GetDateTime(9);
                    }
                    else
                    {
                        Resource.AvailabilityDate = DateTime.Now;
                    }
                    if (!rdr.IsDBNull(10))
                    {
                        Resource.AvailabilityHours = rdr.GetDateTime(10);
                    }
                    else
                    {
                        Resource.AvailabilityHours = DateTime.Now;
                    }
                }
                else
                {
                    Resource.SetColumnDefaults();
                }
            }
            catch (Exception ex)
            {
                Resource.SetColumnDefaults();
                return(Resource);
            }
            finally
            {
                con.Close();
            }
            return(Resource);
        }