Esempio n. 1
0
        private void ShowInfo(string _action, int _id)
        {
            BLL.working_hour   bll   = new BLL.working_hour();
            Model.working_hour model = bll.GetModel(_id);

            BLL.manager tmpmanager = new BLL.manager();

            if (_action == DTEnums.ActionEnum.Edit.ToString()) //修改
            {
                txtDate.Text                 = model.date.ToString("yyyy-MM-dd");
                txtJobOrderName.Text         = bll.GetJobOrderName(model.job_order_id);
                hidJobOrderId.Value          = model.job_order_id.ToString();
                ddlProductType.SelectedIndex = model.product_type;
                ddlServiceType.SelectedIndex = model.service_type;
                txtWorkingContent.Text       = model.working_content;
                ddlStatus.SelectedIndex      = model.status;
                txtWorkingHours.Text         = model.working_hours.ToString();
                txtJourneyHours.Text         = model.journey_hours.ToString();
                txtOvertimeHours.Text        = model.overtime_hours.ToString();

                //绑定附件
                rptAttach.DataSource = model.download_attachs;
                rptAttach.DataBind();
            }
            else if (_action == DTEnums.ActionEnum.View.ToString()) //查看
            {
                txtDate.Text                 = model.date.ToString("yyyy-MM-dd");
                txtJobOrderName.Text         = bll.GetJobOrderName(model.job_order_id);
                hidJobOrderId.Value          = model.job_order_id.ToString();
                ddlProductType.SelectedIndex = model.product_type;
                ddlServiceType.SelectedIndex = model.service_type;
                txtWorkingContent.Text       = model.working_content;
                ddlStatus.SelectedIndex      = model.status;
                txtWorkingHours.Text         = model.working_hours.ToString();
                txtJourneyHours.Text         = model.journey_hours.ToString();
                txtOvertimeHours.Text        = model.overtime_hours.ToString();

                txtDate.Enabled           = false;
                txtJobOrderName.Enabled   = false;
                ddlProductType.Enabled    = false;
                ddlServiceType.Enabled    = false;
                txtWorkingContent.Enabled = false;
                ddlStatus.Enabled         = false;
                ddlProductType.Enabled    = false;
                txtJourneyHours.Enabled   = false;
                txtOvertimeHours.Enabled  = false;
                txtWorkingHours.Enabled   = false;

                btnSubmit.Visible = false;

                //绑定附件
                rptAttach.DataSource = model.download_attachs;
                rptAttach.DataBind();
            }
            else
            {
                hidJobOrderId.Value  = this.job_order_id;
                txtJobOrderName.Text = this.job_order_name;
            }
        }
Esempio n. 2
0
        private bool DoEdit(int _id)
        {
            Model.manager manager = GetAdminInfo();

            bool result = true;

            Model.working_hour model = new Model.working_hour();
            BLL.working_hour   bll   = new BLL.working_hour();

            model.id              = this.id;
            model.date            = DateTime.Parse(txtDate.Text.Trim());
            model.job_order_id    = Convert.ToInt32(hidJobOrderId.Value.Trim());
            model.product_type    = Convert.ToByte(ddlProductType.SelectedIndex);
            model.service_type    = Convert.ToByte(ddlServiceType.SelectedIndex);
            model.working_content = txtWorkingContent.Text.Trim();
            model.status          = Convert.ToByte(ddlStatus.SelectedIndex);
            model.working_hours   = decimal.Parse(txtWorkingHours.Text.ToString());
            model.journey_hours   = decimal.Parse(txtJourneyHours.Text.ToString());
            model.overtime_hours  = decimal.Parse(txtOvertimeHours.Text.ToString());

            //保存附件
            if (model.download_attachs != null)
            {
                model.download_attachs.Clear();
            }
            string hidFileList = Request.Params["hidFileName"];

            if (!string.IsNullOrEmpty(hidFileList))
            {
                string[] fileListArr            = hidFileList.Split(',');
                List <Model.download_attach> ls = new List <Model.download_attach>();
                for (int i = 0; i < fileListArr.Length; i++)
                {
                    string[] fileArr = fileListArr[i].Split('|');
                    if (fileArr.Length == 3)
                    {
                        int    attach_id = int.Parse(fileArr[0]);
                        int    fileSize  = Utils.GetFileSize(fileArr[2]);
                        string fileExt   = Utils.GetFileExt(fileArr[2]);
                        //删除旧文件
                        if (attach_id > 0)
                        {
                            new BLL.download_attach().DeleteFile(attach_id, fileArr[2]);
                        }
                        ls.Add(new Model.download_attach {
                            id = attach_id, article_id = _id, title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt
                        });
                    }
                }
                model.download_attachs = ls;
            }

            if (!bll.Update(model))
            {
                result = false;
            }

            return(result);
        }
Esempio n. 3
0
        private bool DoAdd()
        {
            bool result = true;

            Model.working_hour model = new Model.working_hour();
            BLL.working_hour   bll   = new BLL.working_hour();

            model.user_name = manager.user_name;
            model.date      = DateTime.Parse(txtDate.Text.Trim());
            //model.job_order_id = int.Parse(hidJobOrderId.Value.Trim());
            model.job_order_id    = Convert.ToInt32(hidJobOrderId.Value.Trim());
            model.product_type    = Convert.ToByte(ddlProductType.SelectedIndex);
            model.service_type    = Convert.ToByte(ddlServiceType.SelectedIndex);
            model.working_content = txtWorkingContent.Text.Trim();
            model.status          = Convert.ToByte(ddlStatus.SelectedIndex);
            model.working_hours   = decimal.Parse(txtWorkingHours.Text.ToString());
            model.journey_hours   = decimal.Parse(txtJourneyHours.Text.ToString());
            model.overtime_hours  = decimal.Parse(txtOvertimeHours.Text.ToString());
            model.create_time     = DateTime.Now;

            //保存附件
            string hidFileList = Request.Params["hidFileName"];

            if (!string.IsNullOrEmpty(hidFileList))
            {
                string[] fileListArr            = hidFileList.Split(',');
                List <Model.download_attach> ls = new List <Model.download_attach>();
                for (int i = 0; i < fileListArr.Length; i++)
                {
                    string[] fileArr = fileListArr[i].Split('|');
                    if (fileArr.Length == 3)
                    {
                        int    fileSize = Utils.GetFileSize(fileArr[2]);
                        string fileExt  = Utils.GetFileExt(fileArr[2]);
                        ls.Add(new Model.download_attach {
                            id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt
                        });
                    }
                }
                model.download_attachs = ls;
            }

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return(result);
        }
Esempio n. 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.working_hour model)
 {
     return(dal.Update(model));
 }
Esempio n. 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.working_hour model)
 {
     return(dal.Add(model));
 }
Esempio n. 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.working_hour model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into gm_dt_working_hour(");
            strSql.Append("user_name,date,job_order_id,product_type,service_type,working_content,working_hours,journey_hours,overtime_hours,status,create_time)");
            strSql.Append(" values (");
            strSql.Append("@user_name,@date,@job_order_id,@product_type,@service_type,@working_content,@working_hours,@journey_hours,@overtime_hours,@status,@create_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_name",       SqlDbType.NVarChar,    50),
                new SqlParameter("@date",            SqlDbType.DateTime),
                new SqlParameter("@job_order_id",    SqlDbType.Int,          4),
                new SqlParameter("@product_type",    SqlDbType.TinyInt),
                new SqlParameter("@service_type",    SqlDbType.TinyInt),
                new SqlParameter("@working_content", SqlDbType.NVarChar,  1000),
                new SqlParameter("@working_hours",   SqlDbType.Decimal),
                new SqlParameter("@journey_hours",   SqlDbType.Decimal),
                new SqlParameter("@overtime_hours",  SqlDbType.Decimal),
                new SqlParameter("@status",          SqlDbType.TinyInt),
                new SqlParameter("@create_time",     SqlDbType.DateTime),
                new SqlParameter("@ReturnValue",     SqlDbType.Int)
            };
            parameters[0].Value      = model.user_name;
            parameters[1].Value      = model.date;
            parameters[2].Value      = model.job_order_id;
            parameters[3].Value      = model.product_type;
            parameters[4].Value      = model.service_type;
            parameters[5].Value      = model.working_content;
            parameters[6].Value      = model.working_hours;
            parameters[7].Value      = model.journey_hours;
            parameters[8].Value      = model.overtime_hours;
            parameters[9].Value      = model.status;
            parameters[10].Value     = model.create_time;
            parameters[11].Direction = ParameterDirection.Output;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);

            //附件
            if (model.download_attachs != null)
            {
                StringBuilder strSql4;
                foreach (Model.download_attach models in model.download_attachs)
                {
                    strSql4 = new StringBuilder();
                    strSql4.Append("insert into dt_download_attach(");
                    strSql4.Append("article_id,title,file_path,file_ext,file_size)");
                    strSql4.Append(" values (");
                    strSql4.Append("@article_id,@title,@file_path,@file_ext,@file_size)");
                    SqlParameter[] parameters4 =
                    {
                        new SqlParameter("@article_id", SqlDbType.Int,        4),
                        new SqlParameter("@title",      SqlDbType.NVarChar, 255),
                        new SqlParameter("@file_path",  SqlDbType.NVarChar, 255),
                        new SqlParameter("@file_ext",   SqlDbType.NVarChar, 100),
                        new SqlParameter("@file_size",  SqlDbType.Int, 4)
                    };
                    parameters4[0].Direction = ParameterDirection.InputOutput;
                    parameters4[1].Value     = models.title;
                    parameters4[2].Value     = models.file_path;
                    parameters4[3].Value     = models.file_ext;
                    parameters4[4].Value     = models.file_size;
                    cmd = new CommandInfo(strSql4.ToString(), parameters4);
                    sqllist.Add(cmd);
                }
            }

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[11].Value);
        }
Esempio n. 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.working_hour model)

        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update gm_dt_working_hour set ");
                        strSql.Append("date=@date,");
                        strSql.Append("job_order_id=@job_order_id,");
                        strSql.Append("product_type=@product_type,");
                        strSql.Append("service_type=@service_type,");
                        strSql.Append("working_content=@working_content,");
                        strSql.Append("working_hours=@working_hours,");
                        strSql.Append("journey_hours=@journey_hours,");
                        strSql.Append("overtime_hours=@overtime_hours,");
                        strSql.Append("status=@status");
                        strSql.Append(" where id=@id");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@date",            SqlDbType.DateTime),
                            new SqlParameter("@job_order_id",    SqlDbType.Int,          4),
                            new SqlParameter("@product_type",    SqlDbType.TinyInt),
                            new SqlParameter("@service_type",    SqlDbType.TinyInt),
                            new SqlParameter("@working_content", SqlDbType.NVarChar,  1000),
                            new SqlParameter("@working_hours",   SqlDbType.Decimal),
                            new SqlParameter("@journey_hours",   SqlDbType.Decimal),
                            new SqlParameter("@overtime_hours",  SqlDbType.Decimal),
                            new SqlParameter("@status",          SqlDbType.TinyInt),
                            new SqlParameter("@id",              SqlDbType.Int, 4)
                        };
                        parameters[0].Value = model.date;
                        parameters[1].Value = model.job_order_id;
                        parameters[2].Value = model.product_type;
                        parameters[3].Value = model.service_type;
                        parameters[4].Value = model.working_content;
                        parameters[5].Value = model.working_hours;
                        parameters[6].Value = model.journey_hours;
                        parameters[7].Value = model.overtime_hours;
                        parameters[8].Value = model.status;
                        parameters[9].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        //删除已删除的附件
                        new download_attach().DeleteList(conn, trans, model.download_attachs, model.id);
                        // 添加/修改附件
                        if (model.download_attachs != null)
                        {
                            StringBuilder strSql2;
                            foreach (Model.download_attach models in model.download_attachs)
                            {
                                strSql2 = new StringBuilder();
                                if (models.id > 0)
                                {
                                    strSql2.Append("update dt_download_attach set ");
                                    strSql2.Append("article_id=@article_id,");
                                    strSql2.Append("title=@title,");
                                    strSql2.Append("file_path=@file_path,");
                                    strSql2.Append("file_ext=@file_ext,");
                                    strSql2.Append("file_size=@file_size");
                                    strSql2.Append(" where id=@id");
                                    SqlParameter[] parameters2 =
                                    {
                                        new SqlParameter("@article_id", SqlDbType.Int,        4),
                                        new SqlParameter("@title",      SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_path",  SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_ext",   SqlDbType.NVarChar, 100),
                                        new SqlParameter("@file_size",  SqlDbType.Int,        4),
                                        new SqlParameter("@id",         SqlDbType.Int, 4)
                                    };
                                    parameters2[0].Value = models.article_id;
                                    parameters2[1].Value = models.title;
                                    parameters2[2].Value = models.file_path;
                                    parameters2[3].Value = models.file_ext;
                                    parameters2[4].Value = models.file_size;
                                    parameters2[5].Value = models.id;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql2.ToString(), parameters2);
                                }
                                else
                                {
                                    strSql2.Append("insert into dt_download_attach(");
                                    strSql2.Append("article_id,title,file_path,file_ext,file_size)");
                                    strSql2.Append(" values (");
                                    strSql2.Append("@article_id,@title,@file_path,@file_ext,@file_size)");
                                    SqlParameter[] parameters2 =
                                    {
                                        new SqlParameter("@article_id", SqlDbType.Int,        4),
                                        new SqlParameter("@title",      SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_path",  SqlDbType.NVarChar, 255),
                                        new SqlParameter("@file_ext",   SqlDbType.NVarChar, 100),
                                        new SqlParameter("@file_size",  SqlDbType.Int, 4)
                                    };
                                    parameters2[0].Value = models.article_id;
                                    parameters2[1].Value = models.title;
                                    parameters2[2].Value = models.file_path;
                                    parameters2[3].Value = models.file_ext;
                                    parameters2[4].Value = models.file_size;
                                    DbHelperSQL.ExecuteSql(conn, trans, strSql2.ToString(), parameters2);
                                }
                            }
                        }

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }