Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MilitiaOrganizationSystem
软件工程综合实验中的项目一——民兵编组系统工程目录
组长:何志强
小组成员:刘闯,杨月洋,石稼轩,王凯军
小组成员:刘闯,杨月洋,石佳煊,王凯军
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ public ChildConditionForm_enum(Condition.ChildCondition cc)

for (int i = 0; i < paraNode.ChildNodes.Count; i++)
{
//载入选项
XmlNode selectNode = paraNode.ChildNodes[i];
propertyvaluesListbox.Items.Add(selectNode.Attributes["name"].Value);
}

foreach(string value in cc.Values)
{//设置选中
{
//设置选中
XmlNode selectChildNode = paraNode.SelectSingleNode("selection[@value='" + value + "']");

for (int i = 0; i < paraNode.ChildNodes.Count; i++)
Expand All @@ -49,9 +51,11 @@ public ChildConditionForm_enum(Condition.ChildCondition cc)
}

private void btn_ok_Click(object sender, EventArgs e)
{//ok,条件赋值
{
//条件赋值
if (propertyvaluesListbox.CheckedIndices.Count == 0)
{//没有选择条件
{
//没有选择条件
MessageBox.Show("必须选择一个值!");
closeForm = false;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public ChildConditionForm_group(Condition.ChildCondition cc)
}

private void btn_ok_Click(object sender, EventArgs e)
{//ok,给条件赋值
{
//条件赋值
childCondition.Values.Clear();
TreeNode selectNode = groupTreeView.SelectedNode;
if(selectNode.Name == "未分组")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public ChildConditionForm_string(Condition.ChildCondition cc)

propertyName.Text = paraNode.Attributes["name"].Value;

//选择方法
if(cc.Method == "StartsWith")
{
radio_StartsWith.Checked = true;
Expand All @@ -43,6 +44,7 @@ public ChildConditionForm_string(Condition.ChildCondition cc)

private void btn_ok_Click(object sender, EventArgs e)
{
//检查条件,空则弹出提示,否则条件赋值
if(radio_StartsWith.Checked)
{
if(startwithCombobox.Text == null || startwithCombobox.Text == "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public ConditionForm(Condition currentCondition)

//初始化属性显示
for(int i = 0; i < parameters.Count; i++)
{//添加属性名
{
//添加属性名
System.Xml.XmlNode xn = parameters[i];
parasCheckBox.Items.Add(xn.Attributes["name"].Value);
foreach(Condition.ChildCondition cc in currentCondition.ccList)
Expand Down Expand Up @@ -92,7 +93,8 @@ private void initialPlaceCombobox()
}

private void CCombobox_SelectedIndexChanged(object sender, EventArgs e)
{//选择市变化时,更新区县下拉项
{
//选择市变化时,更新区县下拉项
dCombobox.Items.Clear();
dCombobox.Items.Add("不限");
if(cCombobox.SelectedIndex == 0)
Expand All @@ -110,7 +112,8 @@ private void CCombobox_SelectedIndexChanged(object sender, EventArgs e)
}

private void PCombobox_SelectedIndexChanged(object sender, EventArgs e)
{//选择省变化时,更新市下拉项
{
//选择省变化时,更新市下拉项
cCombobox.Items.Clear();
cCombobox.Items.Add("不限");
cities = PlaceXmlConfig.cities(provinces[pCombobox.SelectedIndex].Attributes["ID"].Value);//城市
Expand All @@ -123,6 +126,7 @@ private void PCombobox_SelectedIndexChanged(object sender, EventArgs e)

private DialogResult showChildConditionDialog(Condition.ChildCondition cc)
{
//打开对应的条件选择窗口
System.Xml.XmlNode paraNode = cc.parameterNode;
Form ccForm = null;
switch(paraNode.Attributes["type"].Value)
Expand All @@ -137,10 +141,10 @@ private DialogResult showChildConditionDialog(Condition.ChildCondition cc)
ccForm = new ChildConditionForm_group(cc);
break;
case "int":
return DialogResult.Cancel;
return DialogResult.Cancel;//计划取消
break;
case "place":
return DialogResult.Cancel;
return DialogResult.Cancel;//计划取消
break;
default:

Expand All @@ -150,20 +154,22 @@ private DialogResult showChildConditionDialog(Condition.ChildCondition cc)
}

private void ConditionListBox_MouseDoubleClick(object sender, MouseEventArgs e)
{//弹出条件编辑
{
//弹出条件编辑
Condition.ChildCondition cc = (Condition.ChildCondition)conditionListBox.SelectedItem;
if(cc == null)
{//为空则什么都不做
{
return;
}
if(showChildConditionDialog(cc) == DialogResult.OK)
{
conditionListBox.Items[conditionListBox.SelectedIndex] = cc;//刷新了显示数据
conditionListBox.Items[conditionListBox.SelectedIndex] = cc;//刷新显示数据
}
}

private void ParasCheckBox_MouseDoubleClick(object sender, MouseEventArgs e)
{//双击选中,并打开一个ChildCondition对话框
{
//双击选中,并打开一个ChildCondition对话框
string name = (string)parasCheckBox.SelectedItem;
Condition.ChildCondition cc = new Condition.ChildCondition(MilitiaXmlConfig.getNodeByName(name));
if (showChildConditionDialog(cc) == DialogResult.OK)
Expand All @@ -186,7 +192,8 @@ private void ParasCheckBox_MouseDoubleClick(object sender, MouseEventArgs e)
}

private void ParasCheckBox_MouseClick(object sender, MouseEventArgs e)
{//阻止默认的单击选中
{
//阻止默认的单击选中
if(parasCheckBox.GetItemChecked(parasCheckBox.SelectedIndex))
{
parasCheckBox.SetItemChecked(parasCheckBox.SelectedIndex, false);
Expand All @@ -198,7 +205,8 @@ private void ParasCheckBox_MouseClick(object sender, MouseEventArgs e)
}

private void btn_ok_Click(object sender, EventArgs e)
{//ok了,生成条件
{
//ok了,生成条件
condition.ccList = conditionListBox.Items.Cast<Condition.ChildCondition>().ToList();
condition.place = provinces[pCombobox.SelectedIndex].Attributes["ID"].Value;
if(cCombobox.SelectedIndex > 0)
Expand All @@ -213,7 +221,8 @@ private void btn_ok_Click(object sender, EventArgs e)
}

private void deleteCondition_Click(object sender, EventArgs e)
{//删除listBox里的条件
{
//删除listBox里的条件
conditionListBox.Items.Remove(conditionListBox.SelectedItem);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
namespace MilitiaOrganizationSystem
{
public class UnZip
{//解压缩
{
//解压缩
private ZipInputStream s;
private string path;//要压缩到的文件夹路径

public UnZip(string zipFile, string fileDir, string psd)
{//加密解压缩
{
//加密解压缩
path = fileDir;
s = new ZipInputStream(File.OpenRead(zipFile.Trim()));
s.Password = md5.encrypt(psd);
}

public List<string> unzipAll()
{//返回成功的一级子文件夹的名称,在这个工程里面,实际上就是databases
{
//返回成功的一级子文件夹的名称,在这个工程里面,实际上就是databases
List<string> databases = new List<string>();
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
Expand All @@ -30,15 +33,19 @@ public List<string> unzipAll()
int index = theEntry.Name.IndexOf('\\');
string rootDir = index >= 0 ? theEntry.Name.Substring(0, index) : "";
if (rootDir == "")
{//是一级文件,这个项目中,一级文件只有导出的xmlFile(分组或民兵数据)
{
//是一级文件,这个项目中,一级文件只有导出的xmlFile(分组或民兵数据)
streamWriter = File.Create(path + "\\" + theEntry.Name);
}
else
{//是多级文件
{
//是多级文件
if (!databases.Contains(rootDir))
{//加入databases
{
//加入databases
if(Directory.Exists(path + "\\" + rootDir))
{//还没有包含在databases中,说明第一次访问这个rootDir,但是如果它已经存在,说明产生了冲突
{
//还没有包含在databases中,说明第一次访问这个rootDir,但是如果它已经存在,说明产生了冲突
continue;
}
databases.Add(rootDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public class Zip
{
private ZipOutputStream s;//流
public Zip(string strZip, string psd, int level)
{//strZip是要压缩的文件名路径,会创建或覆盖;
//psd是压缩文件的密码,之后会被加密
//level是压缩的级别
{
//strZip是要压缩的文件名路径,会创建或覆盖;
//psd是压缩文件的密码,之后会被加密
//level是压缩的级别
s = new ZipOutputStream(File.Create(strZip));//初始化流
s.SetLevel(level);
s.Password = md5.encrypt(psd);//设置密码
Expand Down Expand Up @@ -43,13 +44,16 @@ private void zipOnlyFile(string file, ZipOutputStream s, int startIndex)
}

private void zip(string strFile, ZipOutputStream s, int startIndex)
{//压缩文件夹,startIndex是此文件夹下开始的下标
{
//压缩文件夹,startIndex是此文件夹下开始的下标
if (File.Exists(strFile))
{//如果压缩的是文件,则直接压缩文件
{
//如果压缩的是文件,则直接压缩文件
zipOnlyFile(strFile, s, startIndex);
}
else
{//否则压缩文件夹
{
//否则压缩文件夹
string[] filenames = Directory.GetFileSystemEntries(strFile);
foreach (string file in filenames)
{
Expand All @@ -60,13 +64,15 @@ private void zip(string strFile, ZipOutputStream s, int startIndex)
}

public void addFileOrFolder(string strFile)
{//向压缩文件里加文件或文件夹
{
//向压缩文件里加文件或文件夹
int startIndex = strFile.LastIndexOf(Path.GetFileName(strFile));
zip(strFile, s, startIndex);
}

public void close()
{//关闭,必须调用
{
//关闭,必须调用
s.Finish();
s.Close();
}
Expand Down