using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using DevComponents.DotNetBar;
|
using System.IO;
|
using HH.WMS.Client.Common;
|
using Newtonsoft.Json;
|
|
namespace HH.WMS.Client.frm
|
{
|
public partial class frmAddTemplet : DevComponents.DotNetBar.Metro.MetroForm
|
{
|
public frmAddTemplet()
|
{
|
InitializeComponent();
|
}
|
|
public delegate void DesignDelegate(string path);
|
public event DesignDelegate DesignEvent;
|
|
private void btnCreate_Click(object sender, EventArgs e)
|
{
|
string type = this.cmbType.Text;
|
if (string.IsNullOrEmpty(type))
|
{
|
MessageBox.Show("ÇëÑ¡ÔñÄ£°åÀàÐÍ", "ºÏ·ÊºººÍ");
|
return;
|
}
|
string name = this.txtName.Text;
|
if (string.IsNullOrEmpty(name))
|
{
|
MessageBox.Show("ÇëÊäÈëÄ£°æÃû³Æ", "ºÏ·ÊºººÍ");
|
return;
|
}
|
//»ñÈ¡¿½±´±¨±íÃû³Æ
|
OperateResult or = CreateTemplate(this.cmbType.Text);
|
if (or.Status == ResultStatus.Success)
|
{
|
string path = @"ActionReport/Template/" + name + ".rdlx";
|
EndUserDesigner designer = new EndUserDesigner();//µ÷Óñà¼Ä£°æ
|
DesignEvent += designer.OnDesign;//×¢²áʼþ
|
DesignEvent(path);
|
|
string sr = WebApiManager.HttpWMS_Get("/api/PrintTemplet/CreateTemplet?mac=" + StaticUtil.Mac + "&ip="+StaticUtil.Ip+"&stockCode=" + StaticUtil.StockCode + "&type=" + type + "&name=" + name + ".rdlx");
|
or = JsonConvert.DeserializeObject<OperateResult>(sr);
|
|
|
if (or.Status == ResultStatus.Success)
|
{
|
this.Close();
|
|
designer.ShowDialog();
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
}
|
else
|
{
|
MessageBoxEx.Show(or.Msg);
|
}
|
}
|
else
|
{
|
MessageBox.Show(or.Msg);
|
}
|
}
|
|
#region ¿½±´¸´ÖÆ
|
/// <summary>
|
/// ¿½±´oldlabµÄÎļþµ½newlabÏÂÃæ
|
/// </summary>
|
/// <param name="sourcePath">labÎļþËùÔÚĿ¼(@"~\labs\oldlab")</param>
|
/// <param name="savePath">±£´æµÄÄ¿±êĿ¼(@"~\labs\newlab")</param>
|
/// <param name="ArName">±¨±íÃû³Æ</param>
|
/// <returns>·µ»Ø:true-¿½±´³É¹¦;false:¿½±´Ê§°Ü</returns>
|
public OperateResult CreateTemplate(string type)
|
{
|
string fileName = txtName.Text.Trim();
|
string rootTemplatePath = Application.StartupPath + @"\ActionReport\RootTemplate\" + type + "¸ùÄ£°å.rdlx";
|
if (!File.Exists(rootTemplatePath))
|
{
|
return OperateResult.Error("ÕÒ²»µ½¸ùÄ£°å£¡");
|
}
|
|
string templatePath = Application.StartupPath + @"\ActionReport\Template\";
|
if (!Directory.Exists(templatePath))
|
{
|
Directory.CreateDirectory(templatePath);
|
}
|
|
try
|
{
|
|
string[] labFiles = Directory.GetFiles(templatePath);//Îļþ
|
foreach (string m in labFiles)
|
{
|
if (m.Equals(fileName))
|
{
|
return OperateResult.Error("ÒÑ´æÔÚ¸ÃÄ£°å£¡");
|
}
|
}
|
File.Copy(rootTemplatePath, templatePath + "\\" + fileName + ".rdlx", false);
|
}
|
catch (Exception ex)
|
{
|
return OperateResult.Error(ex.Message);
|
}
|
return OperateResult.Succeed();
|
}
|
#endregion
|
|
private void cmbType_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
|
}
|
}
|
}
|