Ejemplo n.º 1
0
 public void SetData(object sender, EventArgs e)
 {
     frmEventArgs fea = e as frmEventArgs;
     Project pro = fea.obj as Project ;
     project = pro;
     BindUser();
     txtForemanName.Text = pro.ForemanName;
     txtAddress.Text = pro.Address;
     txtPhone.Text = pro.Phone;
     cmbUser.SelectedText = pro.UserName;
     flag = 1; 
 }
Ejemplo n.º 2
0
 public static bool UpdateProject(Project pro)
 {
     return ProjectDAL.UpdateProject(pro) > 0;
 }
Ejemplo n.º 3
0
 public static bool AddProject(Project pro)
 {
     return ProjectDAL.AddProject(pro) > 0 ? true : false;
 }
Ejemplo n.º 4
0
 public static int UpdateProject(Project pro)
 {
     StringBuilder sbSql = new StringBuilder();
     sbSql.Append("update Projects set userID=@userID ,ForemanName=@ForemanName,Phone=@phone,Address=@Address,Schedule=@Schedule ");
     List<OleDbParameter> list = new List<OleDbParameter>();
     OleDbParameter [] param = { 
                              new OleDbParameter("@userID",pro.UserID),
                              new OleDbParameter("@ForemanName",pro.ForemanName),
                              new OleDbParameter("@phone",pro.Phone),
                              new OleDbParameter("@Address",pro.Address),
                              new OleDbParameter("@Schedule",pro.Schedule)
                              };
     list.AddRange(param);
     if (pro.MuDate!=null)
     {
         sbSql.Append(" ,MuDate=@MuDate ");
         list.Add(new OleDbParameter("@MuDate",pro.MuDate));
     }
     if (pro.NiDate!=null)
     {
         sbSql.Append(" ,NiDate=@NiDate ");
         list.Add(new OleDbParameter("@NiDate",pro.NiDate));
     }
     if (pro.PredictCompleteDate!=null)
     {
         sbSql.Append(" ,PredictCompleteDate =@PredictCompleteDate ");
         list.Add(new OleDbParameter("@PredictCompleteDate", pro.PredictCompleteDate));
     }
     if (pro.ShuiDate!=null)
     {
         sbSql.Append(" ,ShuiDate=@ShuiDate ");
         list.Add(new OleDbParameter("@ShuiDate",pro.ShuiDate));
     }
     if (pro.WanDate!=null)
     {
         sbSql.Append(" ,WanDate=@WanDate ");
         list.Add(new OleDbParameter("@WanDate",pro.WanDate));
     }
     if (pro.YouDate!=null)
     {
         sbSql.Append(" ,YouDate=@YouDate ");
         list.Add(new OleDbParameter("@YouDate",pro.YouDate));
     }
     sbSql.Append(" where ProjectID="+pro.ProjectID);
     string sql = sbSql.ToString();
     return AccSqlHelper.ExecuteNonQuery(sql, list.ToArray());
 }
Ejemplo n.º 5
0
        public static List<Project> DTToProject(DataTable dt)
        {
            if (dt==null)
            {
                return null;
            }
            List<Project> list = new List<Project>();
            foreach (DataRow dr in dt.Rows)
            {
                Project pro = new Project();
                if (dr["Address"] == null || dr["Address"].ToString().Equals(""))
                {
                    pro.Address = "";
                }
                else
                {
                    pro.Address = dr["Address"].ToString();
                }

                if (dr["Phone"] == null || dr["Phone"].ToString().Equals(""))
                {
                    pro.Phone = "";
                }
                else
                {
                    pro.Phone = dr["Phone"].ToString();
                }
                if (dr["ForemanName"] == null || dr["ForemanName"].ToString().Equals(""))
                {
                    pro.ForemanName = "";
                }
                else
                {
                    pro.ForemanName = dr["ForemanName"].ToString();
                }

                if (dr["MuDate"] == null || dr["MuDate"].ToString().Equals(""))
                {
                    pro.MuDate = null;
                }
                else
                {
                    pro.MuDate = Convert.ToDateTime(dr["MuDate"]);
                }

                if (dr["ShuiDate"] == null || dr["ShuiDate"].ToString().Equals(""))
                {
                    pro.ShuiDate = null;
                }
                else
                {
                    pro.ShuiDate = Convert.ToDateTime(dr["ShuiDate"]);
                }
                if (dr["RecordDate"] == null || dr["RecordDate"].ToString().Equals(""))
                {
                    pro.RecordDate = null;
                }
                else
                {
                    pro.RecordDate = Convert.ToDateTime(dr["RecordDate"]);
                }
                if (dr["PredictCompleteDate"] == null || dr["PredictCompleteDate"].ToString().Equals(""))
                {
                    pro.PredictCompleteDate = null;
                }
                else
                {
                    pro.PredictCompleteDate = Convert.ToDateTime(dr["PredictCompleteDate"]);
                }
                if (dr["NiDate"] == null || dr["NiDate"].ToString().Equals(""))
                {
                    pro.NiDate = null;
                }
                else
                {
                    pro.NiDate = Convert.ToDateTime(dr["NiDate"]);
                }
                if (dr["YouDate"] == null || dr["YouDate"].ToString().Equals(""))
                {
                    pro.YouDate = null;
                }
                else
                {
                    pro.YouDate = Convert.ToDateTime(dr["YouDate"]);
                }

                if (dr["YouDate"] == null || dr["YouDate"].ToString().Equals(""))
                {
                    pro.YouDate = null;
                }
                else
                {
                    pro.YouDate = Convert.ToDateTime(dr["YouDate"]);
                }
                if (dr["WanDate"] == null || dr["WanDate"].ToString().Equals(""))
                {
                    pro.WanDate = null;
                }
                else
                {
                    pro.WanDate = Convert.ToDateTime(dr["WanDate"]);
                }
                pro.UserID = Convert.ToInt32(dr["UserID"]);
                pro.UserName = UserInfoDAL.GetUserByUserID(pro.UserID).UserName;
                pro.Schedule = Convert.ToInt32(dr["Schedule"]);
                pro.SchedeleName = pro.Schedule == -1 ? "还没有开工" : arrSchedule[pro.Schedule];
                pro.ProjectID = Convert.ToInt32(dr["ProjectID"]);
                list.Add(pro);
            }
            return list;
        }
Ejemplo n.º 6
0
 public static int AddProject(Project pro)
 {
     StringBuilder sqlStart = new StringBuilder();
     StringBuilder sqlEnd = new StringBuilder();
     sqlStart.Append("insert into projects (UserID,ForemanName,Phone,RecordDate,Address,Schedule ");
     sqlEnd.Append(" values (@UserID,@ForemanName,@Phone,@RecordDate,@Address,@Schedule ");
     List<OleDbParameter> list = new List<OleDbParameter>();
     OleDbParameter[] param = { 
                    new OleDbParameter("@UserID",pro.UserID),
                    new OleDbParameter("@ForemanName",pro.ForemanName),
                    new OleDbParameter("@Phone",pro.Phone),
                    new OleDbParameter("@RecordDate",OleDbType.DBDate){Value=pro.RecordDate},
                    new OleDbParameter("@Address",pro.Address),
                    new OleDbParameter("@Schedule",pro.Schedule)
                               };
     list.AddRange(param);
     if (!CheckDateIsNull(pro.ShuiDate))
     {
         sqlStart.Append(" ,ShuiDate ");
         sqlEnd.Append(" ,@ShuiDate ");
         list.Add(new OleDbParameter("@ShuiDate", pro.ShuiDate));
     }
     if (!CheckDateIsNull(pro.NiDate))
     {
         sqlStart.Append(" ,NiDate ");
         sqlEnd.Append(" ,@NiDate ");
         list.Add(new OleDbParameter("@NiDate", pro.NiDate));
     }
     if (!CheckDateIsNull(pro.MuDate))
     {
         sqlStart.Append(" ,MuDate ");
         sqlEnd.Append(" ,@MuDate ");
         list.Add(new OleDbParameter("@MuDate", pro.MuDate));
     }
     if (!CheckDateIsNull(pro.YouDate))
     {
         sqlStart.Append(" ,YouDate ");
         sqlEnd.Append(" ,@YouDate ");
         list.Add(new OleDbParameter("@YouDate", pro.YouDate));
     }
     if (!CheckDateIsNull(pro.WanDate))
     {
         sqlStart.Append(" ,WanDate ");
         sqlEnd.Append(" ,@WanDate ");
         list.Add(new OleDbParameter("@WanDate", pro.WanDate));
     }
     if (!CheckDateIsNull(pro.PredictCompleteDate))
     {
         sqlStart.Append(" ,PredictCompleteDate ");
         sqlEnd.Append(" ,@PredictCompleteDate ");
         list.Add(new OleDbParameter("@PredictCompleteDate", pro.PredictCompleteDate));
     }
     sqlStart.Append(" )");
     sqlEnd.Append(" )");
     string sql = sqlStart.Append(sqlEnd).ToString();
     OleDbParameter[] par = list.ToArray();
     return AccSqlHelper.ExecuteNonQuery(sql, par);
 }
Ejemplo n.º 7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Project pro = new Project();
            pro.Address = txtAddress.Text.Trim() ;
            if (txtForemanName.Text=="")
            {
                MessageBox.Show("没有输入工长姓名");
                txtForemanName.Focus();
                return;
            }
            pro.Schedule = -1;
            pro.ForemanName = txtForemanName.Text.Trim();
           
            
            pro.Phone = txtPhone.Text;

            if (dtPredictCompleteDate.Checked)
            {
                pro.PredictCompleteDate = dtPredictCompleteDate.Value;
            }
            if (dtRecordDate.Checked )
            {
                pro.Schedule = -1;
                pro.RecordDate = dtRecordDate.Value;
            }
            if (dtShuiDate.Checked)
            {
                pro.Schedule = 1;
                pro.ShuiDate = dtShuiDate.Value;
            }
            if (dtNiDate.Checked)
            {
                pro.Schedule = 2;
                pro.NiDate = dtNiDate.Value;
            }
            if (dtMuDate.Checked)
            {
                pro.Schedule = 3;
                pro.MuDate = dtMuDate.Value;
            }
            pro.UserID =(int)cmbUser.SelectedValue;
            if (dtYouDate.Checked)
            {
                pro.Schedule = 4;
                pro.YouDate = dtYouDate.Value;
            }
            if (dtWanDate.Checked)
            {
                pro.Schedule = 0;
                pro.WanDate = dtWanDate.Value;
            }
            if (flag==1)
            {
                pro.ProjectID = project.ProjectID;
                if (ProjectBLL.UpdateProject(pro))
                {
                    
                    Common.MessageBoxShow("修改成功");
                }
                else
                {
                    Common.MessageBoxShow("修改失败");
                }
            }
            else
            {
                if (ProjectBLL.AddProject(pro))
                {
                    MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            
        }