Example #1
0
        private void btnExecute_Click(object sender, RoutedEventArgs e)
        {
            Supervisor x = (Supervisor)this.DataContext;

            if (x.IsValidate())
            {
                if (x.SupervisorID == null)
                {
                    if (x.InsertSupervisorData())
                    {
                        MyMessage.InsertMessage();
                        DialogResult = true;
                    }
                }
                else
                {
                    if (x.UpdateSupervisorData())
                    {
                        MyMessage.UpdateMessage();
                        DialogResult = true;
                    }
                }
            }
        }
Example #2
0
 public SupervisorControl(Supervisor s)
 {
     InitializeComponent();
     this.DataContext   = s;
     btnExecute.Content = "تعديل";
 }
Example #3
0
        public static Supervisor GetSupervisorByID(int?id)
        {
            Supervisor    x   = new Supervisor();
            SqlConnection con = new SqlConnection(BaseDataBase.ConnectionString);
            SqlCommand    com = new SqlCommand("sp_GetSupervisorByID", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            SqlParameter pr = new SqlParameter("@SupervisorID", id);

            com.Parameters.Add(pr);
            try
            {
                con.Open();
                SqlDataReader rd = com.ExecuteReader();
                if (rd.Read())
                {
                    if (!(rd["SupervisorID"] is DBNull))
                    {
                        x.SupervisorID = System.Int32.Parse(rd["SupervisorID"].ToString());
                    }
                    x.FirstName  = rd["FirstName"].ToString();
                    x.LastName   = rd["LastName"].ToString();
                    x.BirthPlace = rd["BirthPlace"].ToString();
                    if (!(rd["DOB"] is DBNull))
                    {
                        x.DOB = System.DateTime.Parse(rd["DOB"].ToString());
                    }
                    x.Gender = rd["Gender"].ToString();
                    x.Job    = rd["Job"].ToString();
                    if (!(rd["Slary"] is DBNull))
                    {
                        x.Slary = System.Single.Parse(rd["Slary"].ToString());
                    }
                    x.Phone         = rd["Phone"].ToString();
                    x.Mobile        = rd["Mobile"].ToString();
                    x.Email         = rd["Email"].ToString();
                    x.MaritalStatus = rd["MaritalStatus"].ToString();
                    if (!(rd["ChildCount"] is DBNull))
                    {
                        x.ChildCount = System.Int32.Parse(rd["ChildCount"].ToString());
                    }
                    x.IdentityImage       = rd["IdentityImage"].ToString();
                    x.PlaceAddress        = rd["PlaceAddress"].ToString();
                    x.ScientificQualifier = rd["ScientificQualifier"].ToString();
                    x.Major = rd["Major"].ToString();
                    if (!(rd["IsActivated"] is DBNull))
                    {
                        x.IsActivated = System.Boolean.Parse(rd["IsActivated"].ToString());
                    }
                    x.NotActivatedReason = rd["NotActivatedReason"].ToString();
                    x.Notes = rd["Notes"].ToString();
                }
                rd.Close();
            }
            catch
            {
                x = null;
            }
            finally
            {
                con.Close();
            }
            return(x);
        }