예제 #1
0
        public object[] CheckEsoppicExist(Esoppics esoppics)
        {
            string sqlStr = string.Format("select {0} from TBLESOPPICS pic where 1=1 ", DomainObjectUtility.GetDomainObjectFieldsString(typeof(Esoppics)));

            sqlStr += " and pic.ITEMCODE = '" + esoppics.Itemcode + "'";
            sqlStr += " and pic.OPCODE = '" + esoppics.Opcode + "' ";
            sqlStr += " and pic.PICSEQ = '" + esoppics.Picseq + "' ";
            return(this.DataProvider.CustomQuery(typeof(Esoppics), new SQLCondition(sqlStr)));
        }
예제 #2
0
        private void listEsopPicsView_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (listPics.SelectedItems.Count > 0)
                {
                    this.imageListCache.Clear();
                    this.pbEsopIMG.Image   = null;
                    this.txtNGPicMemo.Text = string.Empty;
                    this.listPicsNG.SelectedItems.Clear();

                    int      num         = listPics.Items.IndexOf(listPics.SelectedItems[0]);
                    Esoppics selectedPic = (Esoppics)this.listPics.SelectedItems[0].Tag;

                    string filaPath = "";

                    if (_facade == null)
                    {
                        _facade = new SystemSettingFacade(this.DataProvider);
                    }
                    object parameter = _facade.GetParameter("PUBLISHESOPPICSDIRPATH", "PUBLISHEOPSPICSDIRPATHGROUP");

                    if (parameter != null)
                    {
                        //服务器目录路径
                        filaPath = ((Domain.BaseSetting.Parameter)parameter).ParameterAlias;
                    }

                    string fileName = filaPath + selectedPic.Picfullname + ".jpg";

                    try
                    {
                        WebClient wc = new WebClient();
                        wc.Credentials = CredentialCache.DefaultCredentials;
                        Stream fs  = wc.OpenRead(fileName);
                        Image  img = Image.FromStream(fs);
                        this.pbEsopIMG.Size  = img.Size;
                        this.pbEsopIMG.Image = img;
                        fs.Flush();
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }
예제 #3
0
        private void listEsopPicsView_SelectedIndexChanged(object sender, EventArgs e)
        {
            Messages msg = new Messages();

            try
            {
                if (listEsopPicsView.SelectedItems.Count > 0)
                {
                    int      num         = listEsopPicsView.Items.IndexOf(listEsopPicsView.SelectedItems[0]);
                    Esoppics selectedPic = (Esoppics)this.listEsopPicsView.SelectedItems[0].Tag;
                    this.txtPicTitle.Text = selectedPic.Pictitle;
                    this.txtPicDesc.Text  = selectedPic.Picmemo;

                    string filaPath = "";

                    if (_facade == null)
                    {
                        _facade = new SystemSettingFacade(this.DataProvider);
                    }
                    object parameter = _facade.GetParameter("PUBLISHESOPPICSDIRPATH", "PUBLISHEOPSPICSDIRPATHGROUP");

                    if (parameter != null)
                    {
                        //服务器目录路径
                        filaPath = ((Domain.BaseSetting.Parameter)parameter).ParameterAlias;
                    }
                    string    fileName = filaPath + selectedPic.Picfullname + ".jpg";
                    WebClient wc       = new WebClient();
                    wc.Credentials = CredentialCache.DefaultCredentials;
                    Stream fs  = wc.OpenRead(fileName);
                    Image  img = Image.FromStream(fs);
                    this.pbEsopIMG.Size  = img.Size;
                    this.pbEsopIMG.Image = img;
                    fs.Flush();
                    fs.Dispose();
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$Error_FileReadError"));
                ApplicationRun.GetInfoForm().Add(msg);
                clearAll();
                return;
            }
        }
예제 #4
0
        protected override object GetEditObject()
        {
            DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

            if (_esoppicsFacade == null)
            {
                _esoppicsFacade = new EsopPicsFacade(base.DataProvider);
            }

            Esoppics pic = this._esoppicsFacade.CreateNewEsoppics();

            if (string.IsNullOrEmpty(this.HiddenPicSerial.Text))
            {
                pic.Serial = ((Esoppics)_esoppicsFacade.GetEsoppicNextSerial()[0]).Serial;
            }
            else
            {
                pic.Serial = this.HiddenPicSerial.Text;
            }

            string picType = string.Empty;

            if (chkOInstruction.Checked)
            {
                picType = PicType.Operating_Instructions;
            }
            if (chkMInstruction.Checked)
            {
                picType += ("," + PicType.Maintenance_instructions);
                picType  = picType.Trim(',');
            }

            pic.Itemcode = FormatHelper.CleanString(this.txtItemCode.Text, 40);
            pic.Picseq   = Convert.ToInt32(this.txtPICOrderEdit.Text.Trim());
            pic.Opcode   = FormatHelper.CleanString(this.txtOplist.Text, 40);
            pic.Pictitle = FormatHelper.CleanString(this.txtPICTitleEdit.Text, 100);
            pic.Picmemo  = FormatHelper.CleanString(this.txtPICMemoEdit.Text, 40);
            //pic.Pictype = FormatHelper.CleanString(this.DropdownlistPICType.SelectedValue);
            pic.Pictype     = picType;
            pic.Picfullname = pic.Itemcode + "_" + pic.Opcode + "_" + pic.Serial;
            pic.Muser       = this.GetUserCode();
            pic.Mdate       = dbDateTime.DBDate;
            pic.Mtime       = dbDateTime.DBTime;

            return(pic);
        }
예제 #5
0
        protected override void UpdateDomainObject(object domainObject)
        {
            if (_esoppicsFacade == null)
            {
                _esoppicsFacade = new EsopPicsFacade(base.DataProvider);
            }
            this.DataProvider.BeginTransaction();
            Esoppics pic = (Esoppics)domainObject;

            object[] items = _esoppicsFacade.CheckEsoppicExist((Esoppics)domainObject);
            if (items != null && items.Length > 0)
            {
                if (items.Length == 1 && ((Esoppics)items[0]).Serial == this.HiddenPicSerial.Text)
                {
                    this._esoppicsFacade.UpdateEsoppics((Esoppics)domainObject);
                    if (UpLoadFile("EDIT", (Esoppics)domainObject))
                    {
                        this.DataProvider.CommitTransaction();
                        WebInfoPublish.PublishInfo(this, "$ReportDesign_Save_Success", this.languageComponent1);
                    }
                    else
                    {
                        this.DataProvider.RollbackTransaction();
                    }
                }
                else
                {
                    WebInfoPublish.PublishInfo(this, "$Error_Primary_Key_Overlap", this.languageComponent1);
                    return;
                }
            }
            else
            {
                this._esoppicsFacade.UpdateEsoppics((Esoppics)domainObject);
                if (UpLoadFile("EDIT", (Esoppics)domainObject))
                {
                    this.DataProvider.CommitTransaction();
                    WebInfoPublish.PublishInfo(this, "$ReportDesign_Save_Success", this.languageComponent1);
                }
                else
                {
                    this.DataProvider.RollbackTransaction();
                }
            }
        }
예제 #6
0
 public void UpdateEsoppics(Esoppics esoppics)
 {
     this.DataProvider.Update(esoppics);
 }
예제 #7
0
 public void DeleteEsoppics(Esoppics esoppics)
 {
     this.DataProvider.Delete(esoppics);
 }
예제 #8
0
 public void AddEsoppics(Esoppics esoppics)
 {
     this.DataProvider.Insert(esoppics);
 }
예제 #9
0
        private bool UpLoadFile(string action, Esoppics pic)
        {
            if (action == "EDIT" && string.IsNullOrEmpty(this.fileUpload.Value))
            {
                return(true);
            }
            try
            {
                if (_facade == null)
                {
                    _facade = new SystemSettingFacade(this.DataProvider);
                }
                //object parameter = _facade.GetParameter("PICUPLOADPATH", "ESOPPICDIRPATHGROUP");
                //if (parameter != null)
                //{
                //服务器目录路径
                string filePath = System.AppDomain.CurrentDomain.BaseDirectory
                                  + "ESFileUpload";//((Domain.BaseSetting.Parameter)parameter).ParameterAlias;

                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                if (filePath.LastIndexOf('\\') == filePath.Length - 1)
                {
                    filePath = filePath.Substring(0, filePath.Length - 1);
                }

                if (pic != null)
                {
                    DirectoryInfo dir = new DirectoryInfo(filePath);

                    foreach (FileInfo file in dir.GetFiles())
                    {
                        if (file.Name == (pic.Picfullname + ".jpg"))
                        {
                            file.Delete();
                        }
                    }


                    /// '检查文件扩展名字
                    HttpPostedFile postedFile = fileUpload.PostedFile;
                    string         fileName;
                    fileName = System.IO.Path.GetFileName(postedFile.FileName);
                    if (fileName != "")
                    {
                        string currentPath = filePath + "\\" + pic.Picfullname + ".jpg";
                        postedFile.SaveAs(currentPath);
                    }


                    WebInfoPublish.PublishInfo(this, "$Success_UpLoadFile", this.languageComponent1);
                }
                return(true);
                //}
                //else
                //{
                //    WebInfoPublish.PublishInfo(this, "$Error_PicDirPath_NotExist", this.languageComponent1);
                //    return false;
                //}
            }
            catch (Exception ex)
            {
                WebInfoPublish.PublishInfo(this, "$Error_UpLoadFile_Exception", this.languageComponent1);
                return(false);
            }
        }