示例#1
0
        private void btnOpenSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbGrantNo.Text))
            {
                MessageBox.Show("No Grant Number Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                BPMHelper bpmHelper  = new BPMHelper();
                string    resultFile = "";
                string    strGuid    = bpmHelper.GetProcInstGuidByGrantNo(tbGrantNo.Text.Trim());

                if (string.IsNullOrEmpty(strGuid))
                {
                    MessageBox.Show("Invalid Grant Number Entered!");
                    return;
                }

                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.InitialDirectory = "D:\\Wipro";
                openFileDialog1.Filter           = "All files (*.*)|*.*";
                openFileDialog1.FilterIndex      = 2;
                openFileDialog1.RestoreDirectory = true;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    resultFile = openFileDialog1.FileName;
                    FileInfo   openFile = new FileInfo(resultFile);
                    FileStream stream   = openFile.OpenRead();
                    //byte[] buffer = new Byte[stream.Length];
                    BinaryReader r = new BinaryReader(stream);

                    r.BaseStream.Seek(0, SeekOrigin.Begin);    //将文件指针设置到文件开

                    byte[] content = r.ReadBytes((int)r.BaseStream.Length);

                    SqlHelper.SaveAttachment(content, strGuid, openFile.Name, openFile.Extension);
                    MessageBox.Show("Saved Successfully!", "Good Job", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //long fileLength = openFile.Length;
                    //byte[] fileByte = new byte[fileLength];
                    //Stream fileStream = openFile.OpenRead();
                    //fileStream.Read(fileByte, 0, fileLength);

                    //entity.AttachmentContent = fileByte;
                }
            }
        }
示例#2
0
        private void btnUserSearch_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tbUserEmail.Text))
            {
                if (rbUserInfoBPM.Checked == true)
                {
                    BPMHelper bpmHelper = new BPMHelper();
                    DataTable dtGet     = bpmHelper.GetUserInfoByEmailAdId(tbUserEmail.Text);
                    gvUserInfo.DataSource = dtGet;

                    DataTable dtVRGet = bpmHelper.GetVRByAccount(tbUserEmail.Text);
                    grdVR.DataSource = dtVRGet;
                }
                else if (rbUserInfoDLMS.Checked == true)
                {
                    DLMSHelper dlmsHelper = new DLMSHelper();
                    DataTable  dtGet      = dlmsHelper.GetUserInfoByEmailAdId(tbUserEmail.Text);
                    gvUserInfo.DataSource = dtGet;
                }
            }
        }