duheng
2024-06-22 0618fadff0d2e95716db801ef0c7a96ff9e1f20e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using DevExpress.XtraEditors;
using HStation.Dto;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace HStation.WinFrmUI.Xhs.Project
{
    public partial class ProjectUserControl : DevExpress.XtraEditors.XtraUserControl
    {
        public ProjectUserControl()
        {
            InitializeComponent();
        }
 
        private AddXhsProjectInput _AddXhsProjectInput = null;
 
        //验证
        public bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.NameTextEdit.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(this.BtnFileChoice.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.BtnFileChoice, "必选项");
                return false;
            }
            return true;
        }
 
        public AddXhsProjectInput GetData(AddXhsProjectInput model)
        {
            model.Name = this.NameTextEdit.Text.Trim();
            model.CustomerName = this.CustomerNameTextEdit.Text.Trim();
            model.CreateTime = DateTime.Now;
            model.GID = Guid.NewGuid().ToString();
            model.Description = this.DescriptionTextEdit.Text.Trim();
            // model.CreateUserID=
            return model;
        }
 
        //选择文件
        private void BtnFileChoice_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "ZIP Files (*.zip)|*.zip";
            openFileDialog.FilterIndex = 1;
            string selectedFilePath = null;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                selectedFilePath = openFileDialog.FileName;
                string newFileName = selectedFilePath.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)
       ? selectedFilePath.Substring(0, selectedFilePath.Length - 4) + ".hsr"
       : selectedFilePath;
                this.BtnFileChoice.Text = newFileName;
            }
            //   string extractPath = @"C:\Users\ZKC\Desktop\sss";
            //  ZipFile.ExtractToDirectory(extractPath, selectedFilePath);
        }
    }
}