using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreFS.CA06;using Pur.Entity;using Pur.Entity;
using Pur.Entity.configureEntity;
using Core.Mes.Client.Comm.Control;
using Infragistics.Win.UltraWinGrid;
using com.hnshituo.pur.vo;
using Core.Mes.Client.Comm.Tool;
using Pur.require_plan;
using Infragistics.Win;
namespace Pur.Pop_upWindow
{
public partial class FrmPop_upDeliveryLocation : FrmPmsBase
{
public String tips = "0";
public String isNotAll = "1";//0全部
public String isCK = "1";//不可以修改
public String isJIT = "";
public FrmPop_upDeliveryLocation()
{
isCK = "0";//非弹出对话框不需要控制权限
isNotAll = "0";
InitializeComponent();
}
public FrmPop_upDeliveryLocation(OpeBase ob)
{
this.ob = ob;
InitializeComponent();
}
public FrmPop_upDeliveryLocation(OpeBase opeBase, string strd,String strisJIT)
{
// TODO: Complete member initialization
this.ob = opeBase;
this.isNotAll = strd;
this.isJIT = strisJIT;
InitializeComponent();
}
/** 交付地点编码 */
private string deliveryLocationCode;
public string DeliveryLocationCode
{
get { return deliveryLocationCode; }
set { deliveryLocationCode = value; }
}
/** 交付地点 */
private string deliveryLocation;
public string DeliveryLocation
{
get { return deliveryLocation; }
set { deliveryLocation = value; }
}
private void FrmPop_upDeliveryLocation_Load(object sender, EventArgs e)//load
{
ultraExpandableGroupBox1.Expanded = false;
txt_isDefault.SelectedIndex = 0;
Cop_isDefault.SelectedIndex = 0;
txt_isJit.SelectedIndex = 0;
QueryDz();
ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
}
///
/// toolbar菜单
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)// toolbar菜单
{
switch (ToolbarKey)
{
case "Query":
{
QueryDz();
}
break;
case "Add"://新增
{
AddDz();
}
break;
case "update":
{
updateDz();
}
break;
case "delete"://删除
{
deleteDz();
}
break;
case "ESC":
{
EscDz();
}
break;
}
}
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key.ToString())
{
case "Query":
{
QueryDz();
}
break;
case "Add":
{
AddDz();
}
break;
case "update":
{
updateDz();
}
break;
case "delete":
{
deleteDz();
}
break;
case "conFirmation":
{
conFirmationDz();
}
break;
case "doClear":
{
clearDz();
}
break;
case "ESC":
{
EscDz();
}
break;
}
}
///
///
///
private void EscDz()
{
this.Close();
}
///
/// 确认
///
private void conFirmationDz()
{
UltraGridRow uge = ultraGrid1.ActiveRow;
this.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
this.DeliveryLocation = uge.Cells["DeliveryLocation"].Value.ToString();
tips = "1";
this.Close();
}
private void clearDz()
{
UltraGridRow uge = ultraGrid1.ActiveRow;
this.DeliveryLocationCode = "";
this.DeliveryLocation = "";
tips = "1";
this.Close();
}
///
/// 删除
///
private void deleteDz()// 删除
{
try
{
this.Cursor = Cursors.WaitCursor;
UltraGridRow uge = ultraGrid1.ActiveRow;
DeliveryLocationDz Dz = new DeliveryLocationDz();
Dz.Validflag = "0";
Dz.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
Dz.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
Dz.DeleteTime = DateTime.Now;
Dz.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
if (testDZ(Dz.DeliveryLocationCode) == false)
{
return;
}
if (MessageUtil.ShowYesNoAndQuestion("确定删除该地址?") == DialogResult.No)
{
return;
}
CoreResult cRt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "doUpdate", new object[] { Dz });
if (cRt.Resultcode != 0)
{
MessageUtil.ShowTips("删除失败" + cRt.Resultmsg);
return;
}
MessageUtil.ShowTips("删除成功!");
QueryDz();
}
catch (Exception ex)
{
MessageUtil.ShowTips("操作失败:" + ex);
}
finally
{
this.Cursor = Cursors.Default;
}
}
private bool testDZ(String dz)
{
DeliveryLocationDz cRt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { dz });
if (cRt == null)
{
MessageUtil.ShowTips("地址不存在,可能已被废除");
return false;
}
if (cRt.Validflag == "0")
{
MessageUtil.ShowTips("地址信息已作废");
return false;
}
if (isCK == "1")
{
if (cRt.OrgId != UserInfo.GetDeptid())
{
MessageUtil.ShowTips("非地址所属科室/单位,无权限删改");
return false;
}
}
return true;
}
///
/// 修改
///
private void updateDz()// 修改
{
try
{
this.Cursor = Cursors.WaitCursor;
UltraGridRow uge = ultraGrid1.ActiveRow;
DeliveryLocationDz Dz = new DeliveryLocationDz();
if (testInput() == false)
{
return;
}
Dz.InvPhysic = txtPhysicCode.Text.Trim();
Dz.InvPhysicName = txtPhysic.Text.Trim();
Dz.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
Dz.UpdateTime = DateTime.Now;
Dz.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
Dz.IsJit = txt_isJit.Value.ToString().Trim();
Dz.DeliveryLocationCode = uge.Cells["DeliveryLocationCode"].Value.ToString();
Dz.DeliveryLocation = Cop_deliveryLocation.Text.ToString().Trim();
Dz.IsDefault = Cop_isDefault.Value.ToString();
if (testDZ(Dz.DeliveryLocationCode) == false)
{
return;
}
if (MessageUtil.ShowYesNoAndQuestion("确定修改该地址?") == DialogResult.No)
{
return;
}
CoreResult cRt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "doUpdate_D", new object[] { Dz });
if (cRt.Resultcode != 0)
{
MessageUtil.ShowTips("修改失败:" + cRt.Resultmsg);
return;
}
MessageUtil.ShowTips("修改成功!");
QueryDz();
comm.doActiveSelRow(ultraGrid1, "DeliveryLocationCode", Dz.DeliveryLocationCode);
}
catch (Exception ex)
{
MessageUtil.ShowTips("操作失败;" + ex);
}
finally
{
this.Cursor = Cursors.Default;
}
}
///
/// 新增
///
private void AddDz()// 新增
{
////
//if (Cop_isDefault.Text.Equals("否"))
//{
// DeliveryLocationDz Dz1 = new DeliveryLocationDz();
// Dz1.Validflag = "1";
// Dz1.IsDefault = "1";
// DataTable dt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "find", new object[] { Dz1,0,0});
// if (dt.Rows.Count != 0)
// {
// CoreResult cRt1 = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "update_is", new object[] { });
// }
//}
try
{
this.Cursor = Cursors.WaitCursor;
DeliveryLocationDz Dz = new DeliveryLocationDz();
if (testInput() == false)
{
return;
}
Dz.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
Dz.CreateTime = DateTime.Now;
Dz.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
Dz.OrgId = CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid();
Dz.OrgName = CoreFS.SA06.CoreUserInfo.UserInfo.GetDepartment();
Dz.OwnerName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
Dz.OwnerUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
Dz.DeliveryLocationCode = getDELIVERY_LOCATION_CODE();//后台复写
Dz.InvPhysic = txtPhysicCode.Text.Trim();
Dz.IsJit = txt_isJit.Value.ToString().Trim();
Dz.InvPhysicName = txtPhysic.Text.Trim();
Dz.DeliveryLocation = Cop_deliveryLocation.Text.ToString().Trim();
Dz.IsDefault = Cop_isDefault.Value.ToString();
Dz.Validflag = "1";
CoreResult cRt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "doInsert_D", new object[] { Dz });
if (cRt.Resultcode != 0)
{
MessageUtil.ShowTips("添加失败:" + cRt.Resultmsg);
return;
}
MessageUtil.ShowTips("添加成功!");
QueryDz();
comm.doActiveSelRow(ultraGrid1, "DeliveryLocationCode", cRt.Resultmsg);
}
catch (Exception ex)
{
MessageUtil.ShowTips("操作失败:" + ex);
}
finally
{
this.Cursor = Cursors.Default;
}
}
private bool testInput()
{
if (Cop_deliveryLocation.Text.ToString().Trim() == "")
{
MessageUtil.ShowTips("请输入有效地址");
Cop_deliveryLocation.Focus();
return false;
}
if (Cop_isDefault.SelectedIndex == -1)
{
MessageUtil.ShowTips("请指定是否为默认值!");
Cop_isDefault.Focus();
return false;
}
if (String.IsNullOrEmpty(txtPhysic.Text.Trim()))
{
MessageUtil.ShowTips("请指定默认入库库区!");
txtPhysic.Focus();
return false;
}
if (String.IsNullOrEmpty(txtPhysicCode.Text.Trim()))
{
MessageUtil.ShowTips("请指定默认入库库区,库区编码不能为空!");
txtPhysic.Focus();
return false;
}
if (txt_isJit.SelectedIndex==-1)
{
MessageUtil.ShowTips("请指定是否为JIT交付地址!");
txt_isJit.Focus();
return false;
}
return true;
}
///
/// 查询
///
private void QueryDz()// 查询
{
try
{
this.Cursor = Cursors.WaitCursor;
DeliveryLocationDz Dz = new DeliveryLocationDz();
Dz.DeliveryLocationCode = txt_deliveryLocationCode.Text.ToString().Trim();
Dz.DeliveryLocation = txt_deliveryLocation.Text.ToString().Trim();
Dz.IsDefault = txt_isDefault.Value == null ? "" : txt_isDefault.Value.ToString().Trim();
Dz.Validflag = "1";
if (isNotAll == "1")
{
Dz.OrgId = UserInfo.GetDeptid();
}
Dz.IsJit = isJIT;
DataTable dt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "doQuery_D", new object[] { Dz });
GridHelper.CopyDataToDatatable(dt, dataTable1, true);
GridHelper.RefreshAndAutoSize(ultraGrid1);
}
catch (Exception ex)
{
MessageUtil.ShowTips("查询数据失败:"+ex);
}
finally
{
this.Cursor = Cursors.Default;
}
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)//激活行
{
String code=ultraGrid1.ActiveRow.Cells["deliveryLocationCode"].Value.ToString().Trim();
if (String.IsNullOrEmpty(code))
{
return;
}
DeliveryLocationDz cRt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { code });
Cop_deliveryLocationCode.Text = cRt.DeliveryLocationCode;
Cop_deliveryLocation.Text = cRt.DeliveryLocation;
Cop_isDefault.Value = cRt.IsDefault;
txtPhysic.Text = cRt.InvPhysicName;
txtPhysicCode.Text = cRt.InvPhysic;
txt_isJit.Value = cRt.IsJit;
}
///
/// 获取交付地点编码
///
///
public String getDELIVERY_LOCATION_CODE()// 获取交付地点编码
{
DataTable dt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "findAll", new object[] { });
string code = "0";
code = (dt.Rows.Count+1).ToString();
while (code.Length < 5)
{
code = "0" + code;
}
return code;
}
private void txtPhysic_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
frmPopActualSeat popAs = new frmPopActualSeat(this.ob, "0");
popAs.ShowDialog();
if (popAs.Tips=="1")
{
txtPhysic.Text = popAs.DeliveryLocation;
txtPhysicCode.Text = popAs.DeliveryLocationCode;
}
}
}
}