Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                IniData();
                lblParent.Text      = "";
                lblFolderId.Visible = false;
                tb_AttachmentService attSer = new tb_AttachmentService();
                if (base.Request["Id"] != null)
                {
                    this.btnAdd.Visible = false;

                    tb_Attachment attachment = attSer.GetListArrayByParentId(Convert.ToInt32(base.Request["Id"]));
                    txtAttName.Text  = attachment.MainName;
                    txtRemark.Text   = attachment.Remark;
                    txtVersion.Text  = attachment.version;
                    lblFolderId.Text = attachment.Folder_Id.ToString();
                    lblParent.Text   = attachment.FolderName;
                    lblAttName.Text  = attachment.fileName;
                }
                else
                {
                    this.btnUpdate.Visible = false;
                }
            }
        }
Ejemplo n.º 2
0
        public int AddSomAttachments(tb_Attachment attachments)
        {
            int id = 0;

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                try
                {
                    objCommand.Parameters.Clear();
                    id = attachmentSer.Add(attachments, objCommand);



                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // string url="<script>window.open('55.htm', '','fullscreen=yes')</script>";

                // Response.Write(url);
                //if (1 == 1)
                //{
                //    return;
                //}

                if (Request["id"] != null)
                {
                    tb_AttachmentService attSer = new tb_AttachmentService();
                    tb_Attachment        atts   = attSer.GetListArrayByParentId_Pre(Request["id"]);
                    if (atts != null)
                    {
                        string qizhui = System.Web.HttpContext.Current.Request.MapPath("Attachment/") + Request["id"];

                        string fileExtension = atts.fileName.Substring(atts.fileName.LastIndexOf(".") + 1).ToLower();



                        if (fileExtension == "doc" || fileExtension == "docx")
                        {
                            if (File.Exists(qizhui + "." + "htm") == false)
                            {
                                WordToHtml(qizhui + "." + fileExtension, qizhui + ".htm");
                            }
                            // url = "/Attachment/" + Request["id"] + ".htm";
                            Response.Redirect("~/Attachment/" + Request["id"] + ".htm");
                        }

                        else if (fileExtension == "xlsx" || fileExtension == "xls")
                        {
                            if (File.Exists(qizhui + "." + "htm") == false)
                            {
                                ExcelConvertToHtml(qizhui + "." + fileExtension, qizhui + ".htm");
                            }
                            //  url = "/Attachment/" + Request["id"] + ".htm";
                            Response.Redirect("~/Attachment/" + Request["id"] + ".htm");
                        }
                        else
                        {
                            Response.Redirect("~/Attachment/" + Request["id"] + "." + fileExtension);


                            //Response.ContentType = atts.FileType;
                            //Response.BinaryWrite((byte[])atts.fileNo);
                            //Response.Write(atts.fileName.ToString());
                        }
                    }

                    // Response.Write("<script>window.close();window.opener=null;</script>");
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// treeview
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public List <tb_Attachment> GetListArray_TV(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select MainName,id,tb_Attachment.folder_Id, ParentId,createTime");
            strSql.Append(" FROM tb_Attachment left join tb_Folder on tb_Attachment.folder_Id=tb_Folder.folder_Id");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where 1=1 " + strWhere);
            }

            strSql.Append(" order by  MainName,createTime desc");
            List <tb_Attachment> list = new List <tb_Attachment>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader objReader = objCommand.ExecuteReader())
                {
                    while (objReader.Read())
                    {
                        tb_Attachment model = new tb_Attachment();
                        object        ojb;
                        ojb = objReader["id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.id = (int)ojb;
                        }
                        ojb = objReader["Folder_Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Folder_Id = (int)ojb;
                        }

                        ojb = objReader["ParentId"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Parentd = ojb.ToString();
                        }

                        ojb = objReader["createTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.createTime = Convert.ToDateTime(ojb);
                        }

                        model.MainName = objReader["MainName"].ToString();
                        list.Add(model);
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(tb_Attachment model, SqlCommand objCommand)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Attachment set ");
            if (model.Folder_Id != null)
            {
                strSql.Append("Folder_Id=" + model.Folder_Id + ",");
            }
            if (model.fileName != null)
            {
                strSql.Append("fileName='" + model.fileName + "',");
            }
            if (model.fileNo != null)
            {
                strSql.Append("fileNo=@fileNo,");



                SqlParameter pp = new System.Data.SqlClient.SqlParameter("@fileNo", System.Data.SqlDbType.Image, model.fileNo.Length);
                pp.Value = model.fileNo;
                objCommand.Parameters.Add(pp);
            }
            if (model.createTime != null)
            {
                strSql.Append("createTime='" + model.createTime + "',");
            }
            if (model.userName != null)
            {
                strSql.Append("userName='******',");
            }
            if (model.version != null)
            {
                strSql.Append("version='" + model.version + "',");
            }

            if (model.Remark != null)
            {
                strSql.Append("Remark='" + model.Remark + "',");
            }

            if (model.MainName != null)
            {
                strSql.Append("MainName='" + model.MainName + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where id=" + model.id + "");
            objCommand.CommandText = strSql.ToString();
            objCommand.ExecuteNonQuery();
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                if (Request["id"]!=null)
                {
                    tb_AttachmentService attSer = new tb_AttachmentService();
                    tb_Attachment atts = attSer.GetListArrayByParentId_Down( Request["id"]);
                    if (atts != null )
                    {
                        string qizhui = System.Web.HttpContext.Current.Request.MapPath("Attachment/") + Request["id"];

                        string fileExtension = atts.fileName.Substring(atts.fileName.LastIndexOf(".") + 1).ToLower();

                        string url = qizhui + "." + fileExtension;
                        down1(Request["id"]+"." + fileExtension, url);

                       

                      


                        //Response.Buffer = true;
                        //Page.Response.Clear();//清除缓冲区所有内容
                        //Page.Response.ContentType = "application/octet-stream";
                        //Page.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(atts.fileName));
                        //byte[] file;
                        //if (atts.fileNo == null)
                        //{
                        //    file = new byte[0];
                        //}
                        //else
                        //{
                        //    file = (Byte[])atts.fileNo;//读出数据
                        //}
                        //int a = file.Length;
                        //if (atts.fileNo != null)
                        //{
                        //    Response.BinaryWrite(file);
                        //}
                        //Response.Flush();
                        //Response.End();

                    }

                  // Response.Write("<script>window.close();window.opener=null;</script>"); 
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public tb_Attachment ReaderBind(IDataReader dataReader)
        {
            tb_Attachment model = new tb_Attachment();
            object        ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = (int)ojb;
            }
            ojb = dataReader["Folder_Id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Folder_Id = (int)ojb;
            }
            model.fileName = dataReader["fileName"].ToString();
            //ojb = dataReader["fileNo"];
            //if (ojb != null && ojb != DBNull.Value)
            //{
            //    model.fileNo = (byte[])ojb;
            //}

            ojb = dataReader["FileType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FileType = ojb.ToString();
            }
            ojb = dataReader["createTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.createTime = (DateTime)ojb;
            }
            model.userName = dataReader["userName"].ToString();
            model.version  = dataReader["version"].ToString();
            model.Remark   = dataReader["Remark"].ToString();
            model.MainName = dataReader["MainName"].ToString();
            ojb            = dataReader["Folder_NAME"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FolderName = ojb.ToString();
            }
            return(model);
        }
Ejemplo n.º 8
0
 public bool UpdateSomAttachments(tb_Attachment attachments)
 {
     using (SqlConnection conn = DBHelp.getConn())
     {
         conn.Open();
         SqlTransaction tan        = conn.BeginTransaction();
         SqlCommand     objCommand = conn.CreateCommand();
         objCommand.Transaction = tan;
         try
         {
             objCommand.Parameters.Clear();
             attachmentSer.Update(attachments, objCommand);
             tan.Commit();
         }
         catch (Exception)
         {
             tan.Rollback();
             return(false);
         }
         return(true);
     }
 }
Ejemplo n.º 9
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtAttName.Text.Trim() == "")
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请填写文件名称!');</script>");
                    return;
                }

                if (lblParent.Text == "" || lblParent.Text == "内部文件")
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请选择一个文件!');</script>");
                    return;
                }
                tb_Attachment att = new tb_Attachment();
                att.createTime = DateTime.Now;
                att.MainName   = txtAttName.Text;
                att.Folder_Id  = Convert.ToInt32(lblFolderId.Text);
                att.Remark     = txtRemark.Text;
                att.userName   = Session["LoginName"].ToString();
                att.version    = txtVersion.Text;

                att.id = Convert.ToInt32(base.Request["Id"]);
                HttpFileCollection files = HttpContext.Current.Request.Files;

                string fileName, fileExtension;
                fileExtension = "";
                HttpPostedFile postedFile = null;
                for (int iFile = 0; iFile < files.Count; iFile++)
                {
                    ///'检查文件扩展名字
                    postedFile = files[iFile];
                    //string fileName, fileExtension;
                    fileName = System.IO.Path.GetFileName(postedFile.FileName);
                    if (fileName != "")
                    {
                        att.fileName  = fileName;
                        fileExtension = System.IO.Path.GetExtension(fileName);
                        string fileType = postedFile.ContentType.ToString();    //文件类型
                        att.FileType = fileType;
                        System.IO.Stream streamFile = postedFile.InputStream;   //建立数据流对象
                        int    fileLength           = postedFile.ContentLength; //文件长度以字节为单位
                        byte[] fileData             = new Byte[fileLength];     //新建一个数组
                        streamFile.Read(fileData, 0, fileLength);               //将这个数据流读取到数组中
                        att.fileNo = fileData;
                    }
                }

                tb_AttachmentManager attMan = new tb_AttachmentManager();
                if (attMan.UpdateSomAttachments(att))
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('保存成功!');</script>");
                    if (att.fileNo != null && fileExtension != "")
                    {
                        if (lblAttName.Text != "")
                        {
                            string attName = System.Web.HttpContext.Current.Request.MapPath("Attachment/") + att.id + lblAttName.Text.Substring(lblAttName.Text.LastIndexOf("."));
                            string ban     = System.Web.HttpContext.Current.Request.MapPath("Attachment/") + att.id;
                            if (File.Exists(attName))
                            {
                                try
                                {
                                    File.Delete(attName);
                                    File.Delete(ban + ".htm");
                                    File.Delete(ban + ".files");
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }


                        string qizhui = System.Web.HttpContext.Current.Request.MapPath("Attachment/") + att.id;
                        postedFile.SaveAs(qizhui + fileExtension);
                        fileExtension = fileExtension.Substring(1, fileExtension.Length - 1).ToLower();

                        if (fileExtension == "doc" || fileExtension == "docx")
                        {
                            WordToHtml(qizhui + "." + fileExtension, qizhui + ".htm");
                        }

                        else if (fileExtension == "xlsx" || fileExtension == "xls")
                        {
                            ExcelConvertToHtml(qizhui + "." + fileExtension, qizhui + ".htm");
                        }
                    }
                    Response.Redirect("~/WfAttachmentList.aspx");
                }
                else
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('保存失败!');</script>");
                    // Response.Redirect("~/WfAttachmentList.aspx");
                }
            }
            catch (Exception EX)
            {
                base.ClientScript.RegisterStartupScript(base.GetType(), null, string.Format("<script>alert('{0}');</script>", EX.Message.ToString()));
            }
        }
Ejemplo n.º 10
0
        public int Insert(SPKHeaderModel hdr, List <SPKAdditionalModel> lsAdditional, SPKEquipmentModel misc, List <SPKAttachmentModel> attchs, int docType, out string errMsg)
        {
            errMsg = string.Empty;
            imap   = config.CreateMapper();
            int _spkId = 0;

            tb_spkHdr       hdrEnt        = new tb_spkHdr();
            tb_KetTambahan  miscEnt       = new tb_KetTambahan();
            tb_PerlTambahan additionalEnt = new tb_PerlTambahan();

            using (TDMDBEntities context = new TDMDBEntities())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        imap   = config.CreateMapper();
                        hdrEnt = imap.Map <SPKHeaderModel, tb_spkHdr>(hdr);
                        context.tb_spkHdr.Add(hdrEnt);
                        result_affected = context.SaveChanges();
                        _spkId          = hdrEnt.Id;

                        foreach (var item in lsAdditional)
                        {
                            additionalEnt.No             = item.No;
                            additionalEnt.SPKId          = _spkId;
                            additionalEnt.AdditionalItem = item.Additional;
                            context.tb_PerlTambahan.Add(additionalEnt);
                            result_affected += context.SaveChanges();
                        }

                        //miscEnt = imap.Map<SPKEquipmentModel, tb_KetTambahan>(misc);
                        //miscEnt.SPKId = _spkId;
                        //context.tb_KetTambahan.Add(miscEnt);
                        //result_affected += context.SaveChanges();

                        foreach (var item in attchs)
                        {
                            tb_Attachment attchEnt = new tb_Attachment();
                            attchEnt.Attachment     = item.Attachment;
                            attchEnt.AttachmentName = item.AttachmentName;
                            attchEnt.DocType        = item.DocType;
                            attchEnt.DocId          = _spkId;
                            attchEnt.CreatedBy      = "SYSTEM";
                            attchEnt.CreatedDate    = DateTime.Now;
                            context.tb_Attachment.Add(attchEnt);
                            result_affected += context.SaveChanges();
                        }

                        //insert to worklist
                        tb_Worklist _entWorklist = new tb_Worklist();
                        _entWorklist.DocId        = _spkId;
                        _entWorklist.DocType      = docType;
                        _entWorklist.Status       = MyEnums.workflowStatus.PENDING.ToString();
                        _entWorklist.StartDate    = DateTime.Now;
                        _entWorklist.CurrLevel    = 0;
                        _entWorklist.NextApprover = Convert.ToInt32(new WorkflowSettingBLL().GetNextActorId(docType, _entWorklist.CurrLevel + 1));
                        _entWorklist.CreatedBy    = hdr.CreatedBy;
                        _entWorklist.CreatedDate  = DateTime.Now;
                        context.tb_Worklist.Add(_entWorklist);
                        result_affected += context.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        errMsg = ex.Message;
                    }
                }
            }

            return(_spkId);
        }
Ejemplo n.º 11
0
        public int Update(SPKHeaderModel hdr, List <SPKAdditionalModel> lsAdditional, SPKEquipmentModel misc, List <SPKAttachmentModel> attchs, int docType, WorklistModel wrkl, out string errMsg)
        {
            errMsg          = string.Empty;
            imap            = config.CreateMapper();
            result_affected = 0;
            tb_spkHdr           hdrEnt          = new tb_spkHdr();
            tb_KetTambahan      miscEnt         = new tb_KetTambahan();
            tb_PerlTambahan     additionalEnt   = new tb_PerlTambahan();
            tb_Worklist_Archive worklistArchive = new tb_Worklist_Archive();

            using (TDMDBEntities context = new TDMDBEntities())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        var update = context.tb_spkHdr.SingleOrDefault(x => x.Id == hdr.Id);
                        if (update != null)
                        {
                            update.SPKDate         = hdr.SPKDate;
                            update.JanjiPenyerahan = hdr.JanjiPenyerahan;
                            update.LOTNo           = hdr.LOTNo;
                            update.Buyer           = hdr.Buyer;
                            update.BuyerAddress    = hdr.BuyerAddress;
                            update.KTP             = hdr.KTP;
                            update.Phone           = hdr.Phone;
                            update.STNKName        = hdr.STNKName;
                            update.STNKAddress     = hdr.STNKAddress;
                            update.Email           = hdr.Email;
                            update.Branch          = hdr.Branch;
                            update.Merk            = hdr.Merk;
                            update.Warna           = hdr.Warna;
                            update.Karoseri        = hdr.Karoseri;
                            update.MachineNo       = hdr.MachineNo;
                            update.RangkaNo        = hdr.RangkaNo;
                            update.Pembiayaan      = hdr.Pembiayaan;
                            update.Year            = hdr.Year;
                            update.Via             = hdr.Via;
                            update.PercentageBunga = hdr.PercentageBunga;
                            update.OTRPrice        = hdr.OTRPrice;
                            update.KaroseriPrice   = hdr.KaroseriPrice;
                            update.TotalPrice      = hdr.TotalPrice;
                            update.DP           = hdr.DP;
                            update.TandaJadi    = hdr.TandaJadi;
                            update.Pembayaran   = hdr.Pembayaran;
                            update.TransferVia  = hdr.TransferVia;
                            update.AlamatKirim  = hdr.AlamatKirim;
                            update.City         = hdr.City;
                            update.IsKaroseri   = hdr.IsKaroseri;
                            update.KaroseriDesc = hdr.KaroseriDesc;
                            update.IsOnTR       = hdr.IsOnTR;
                            update.IsOffTR      = hdr.IsOffTR;
                            update.IsChooseNo   = hdr.IsChooseNo;
                            update.ChooseNo     = hdr.ChooseNo;
                            update.ModifiedBy   = hdr.ModifiedBy;
                            update.ModifiedDate = DateTime.Now;
                            result_affected     = context.SaveChanges();

                            #region ::ADDITIONAL ITEMS::
                            //remove additional items
                            var _qryAdditional = context.tb_PerlTambahan.Where(x => x.SPKId == hdr.Id);
                            context.tb_PerlTambahan.RemoveRange(_qryAdditional);
                            context.SaveChanges();

                            //add additional items
                            foreach (var item in lsAdditional)
                            {
                                additionalEnt.No             = item.No;
                                additionalEnt.SPKId          = hdr.Id;
                                additionalEnt.AdditionalItem = item.Additional;
                                context.tb_PerlTambahan.Add(additionalEnt);
                                result_affected += context.SaveChanges();
                            }
                            #endregion

                            #region ::ATTACHMENTS::

                            foreach (var item in attchs)
                            {
                                tb_Attachment attchEnt = new tb_Attachment();
                                attchEnt.Attachment     = item.Attachment;
                                attchEnt.AttachmentName = item.AttachmentName;
                                attchEnt.DocType        = item.DocType;
                                attchEnt.DocId          = hdr.Id;
                                attchEnt.CreatedBy      = "SYSTEM";
                                attchEnt.CreatedDate    = DateTime.Now;
                                context.tb_Attachment.Add(attchEnt);
                                result_affected += context.SaveChanges();
                            }
                            #endregion

                            #region ::WORKFLOW APPROVAL::
                            var _updWorklist = context.tb_Worklist.SingleOrDefault(x => x.DocId == hdr.Id && x.DocType == docType);
                            if (wrkl.Actioner.ToLower() == MyEnums.actionStatus.APPROVE.ToString().ToLower() || wrkl.Actioner.ToLower() == MyEnums.actionStatus.ACKNOWLEDGE.ToString().ToLower())
                            {
                                if (_updWorklist != null)
                                {
                                    worklistArchive              = imap.Map <tb_Worklist, tb_Worklist_Archive>(_updWorklist);
                                    worklistArchive.RespondDate  = DateTime.Now;
                                    worklistArchive.Actioner     = wrkl.Actioner;
                                    worklistArchive.LastActor    = wrkl.Actor;
                                    worklistArchive.CreatedBy    = _updWorklist.CreatedBy;
                                    worklistArchive.CreatedDate  = _updWorklist.CreatedDate;
                                    worklistArchive.ModifiedBy   = hdr.CreatedBy;
                                    worklistArchive.ModifiedDate = DateTime.Now;
                                    worklistArchive.LastLevel    = _updWorklist.CurrLevel + 1;
                                    worklistArchive.IsCompleted  = new WorkflowSettingBLL().CheckIsWorkflowCompleted(docType, (int)worklistArchive.LastLevel);
                                    if (worklistArchive.IsCompleted)
                                    {
                                        worklistArchive.Status = MyEnums.workflowStatus.COMPLETED.ToString();
                                    }
                                    context.tb_Worklist_Archive.Add(worklistArchive);
                                    context.SaveChanges();
                                    if (!worklistArchive.IsCompleted)
                                    {
                                        //update status worklist
                                        _updWorklist.CurrLevel    = _updWorklist.CurrLevel + 1;
                                        _updWorklist.ModifiedBy   = hdr.ModifiedBy;
                                        _updWorklist.ModifiedDate = DateTime.Now;
                                        _updWorklist.NextApprover = Convert.ToInt32(new WorkflowSettingBLL().GetNextActorId(docType, _updWorklist.CurrLevel + 1));
                                        result_affected          += context.SaveChanges();
                                    }
                                    else
                                    {
                                        var removeDocId = context.tb_Worklist.Where(x => x.DocId == hdr.Id);
                                        context.tb_Worklist.RemoveRange(removeDocId);
                                        result_affected += context.SaveChanges();
                                    }
                                }
                            }
                            else if (wrkl.Actioner.ToLower() == MyEnums.actionStatus.REJECT.ToString().ToLower())
                            {
                                worklistArchive              = imap.Map <tb_Worklist, tb_Worklist_Archive>(_updWorklist);
                                worklistArchive.RespondDate  = DateTime.Now;
                                worklistArchive.Actioner     = wrkl.Actioner;
                                worklistArchive.LastActor    = wrkl.Actor;
                                worklistArchive.CreatedBy    = _updWorklist.CreatedBy;
                                worklistArchive.CreatedDate  = _updWorklist.CreatedDate;
                                worklistArchive.ModifiedBy   = hdr.CreatedBy;
                                worklistArchive.ModifiedDate = DateTime.Now;
                                worklistArchive.LastLevel    = _updWorklist.CurrLevel + 1;
                                worklistArchive.IsCompleted  = true;
                                context.tb_Worklist_Archive.Add(worklistArchive);
                                context.SaveChanges();

                                var removeDocId = context.tb_Worklist.Where(x => x.DocId == hdr.Id);
                                context.tb_Worklist.RemoveRange(removeDocId);
                                context.SaveChanges();
                            }
                            #endregion

                            transaction.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        errMsg = ex.Message == null ? ex.InnerException.Message : ex.Message;
                    }
                }
            }
            return(result_affected);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 预览
        /// </summary>
        public tb_Attachment GetListArrayByParentId_Pre(string id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select MainName,id,tb_Attachment.folder_Id,fileNo,fileName,fileType,createTime,userName,version,Remark ");
            strSql.Append(" FROM tb_Attachment  ");

            strSql.Append(" where id=" + id);

            tb_Attachment model = new tb_Attachment();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        object ojb;
                        ojb = dataReader["id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.id = (int)ojb;
                        }
                        ojb = dataReader["folder_Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Folder_Id = (int)ojb;
                        }


                        model.fileName = dataReader["fileName"].ToString();
                        ojb            = dataReader["FileType"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.FileType = ojb.ToString();
                        }
                        ojb = dataReader["createTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.createTime = (DateTime)ojb;
                        }
                        model.userName = dataReader["userName"].ToString();
                        model.version  = dataReader["version"].ToString();
                        model.Remark   = dataReader["Remark"].ToString();
                        model.MainName = dataReader["MainName"].ToString();
                        //ojb = dataReader["Folder_NAME"];
                        //if (ojb != null && ojb != DBNull.Value)
                        //{
                        //    model.FolderName = ojb.ToString();
                        //}
                        ojb = dataReader["fileNo"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.fileNo = (byte[])ojb;
                        }
                    }
                }
            }
            return(model);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_Attachment model, SqlCommand objCommand)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.Folder_Id != null)
            {
                strSql1.Append("Folder_Id,");
                strSql2.Append("" + model.Folder_Id + ",");
            }
            if (model.fileName != null)
            {
                strSql1.Append("fileName,");
                strSql2.Append("'" + model.fileName + "',");
            }
            if (model.fileNo != null)
            {
                strSql1.Append("fileNo,");
                strSql2.Append("@fileNo,");

                SqlParameter pp = new System.Data.SqlClient.SqlParameter("@fileNo", System.Data.SqlDbType.Image, model.fileNo.Length);
                pp.Value = model.fileNo;
                objCommand.Parameters.Add(pp);
            }
            if (model.FileType != null)
            {
                strSql1.Append("FileType,");
                strSql2.Append("'" + model.FileType + "',");
            }

            if (model.createTime != null)
            {
                strSql1.Append("createTime,");
                strSql2.Append("'" + model.createTime + "',");
            }
            if (model.userName != null)
            {
                strSql1.Append("userName,");
                strSql2.Append("'" + model.userName + "',");
            }
            if (model.version != null)
            {
                strSql1.Append("version,");
                strSql2.Append("'" + model.version + "',");
            }

            strSql1.Append("Remark,");
            strSql2.Append("'" + model.Remark + "',");

            strSql1.Append("MainName,");
            strSql2.Append("'" + model.MainName + "',");

            strSql.Append("insert into tb_Attachment(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            objCommand.CommandText = strSql.ToString();



            int    result;
            object obj = objCommand.ExecuteScalar();

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }