using C1.Silverlight.FlexGrid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace LHSM.RHY.Foundation
{
public partial class RPTD_BUDGET_ZXF : UserControl
{
private string Status = ""; //录入状态与审核状态 录入状态分为下面3个状态
private const string SB_STATUS = "1";
private const string TG_STATUS = "2";
private const string TH_STATUS = "3";
public RPTD_BUDGET_ZXF()
{
InitializeComponent();
}
public RPTD_BUDGET_ZXF(string ss)
: this()
{
Status = ss;
ButLoad();
loadYearAndBB();
//Search();
InitGridSum();
}
private Dictionary<string, string> GridCountValue = new Dictionary<string, string>();
private void InitGridSum()
{
//4,5,6列改动,第3列计算
GridCountValue.Add("3,4,5", "2");
GridCountValue.Add("7,8,9", "6");
GridCountValue.Add("13,14,15", "12");
GridCountValue.Add("17,18,19", "16");
GridCountValue.Add("23,24,25", "22");
GridCountValue.Add("27,28,29", "26");
GridCountValue.Add("33,34,35", "32");
GridCountValue.Add("37,38,39", "36");
GridCountValue.Add("43,44,45", "42");
GridCountValue.Add("47,48,49", "46");
GridCountValue.Add("53,54,55", "52");
GridCountValue.Add("57,58,59", "56");
ds.Add("9,10,11,12,13,14,15,16,17,18,19,20", 8);
ds.Add("22,23", 21);
ds.Add("38,39,40,41,42,43,44", 37);
}
private void loadYearAndBB()
{
LHSysDB<string, string> dbl = new LHSysDB<string, string>();
dbl.InteractionMeans("RPTD_GetYSND", "", new InteractionCallback<string>(ResultYSND));
//LHSysDB<string, List<ClsRPTD_BUDGET_VERSION>> dbl = new LHSysDB<string, List<ClsRPTD_BUDGET_VERSION>>();
//dbl.InteractionMeans("RPTD_BUDGET_VERSIONLoad", "", new InteractionCallback<List<ClsRPTD_BUDGET_VERSION>>(ResultRptdBBLoad));
}
private string m_year = "2018";
private void ResultYSND(PostResultData<string> obj, object state)
{
//上一个版本
m_year = obj.Result;
LHSysDB<string, List<ClsRPTD_BUDGET_VERSION>> dbl = new LHSysDB<string, List<ClsRPTD_BUDGET_VERSION>>();
dbl.InteractionMeans("RPTD_BUDGET_VERSIONLoad", "", new InteractionCallback<List<ClsRPTD_BUDGET_VERSION>>(ResultRptdBBLoad));
}
private List<ClsRPTD_BUDGET_VERSION> YsBbs;
private void ResultRptdBBLoad(PostResultData<List<ClsRPTD_BUDGET_VERSION>> obj, object state)
{
if (obj.Result != null)
{
List<string> years = new List<string>();
YsBbs = obj.Result;
if (YsBbs != null)
{
for (int i = 0; i < YsBbs.Count; i++)
{
if (!years.Contains(YsBbs.Nd))
{
years.Add(YsBbs.Nd);
}
}
}
if (years.Contains(m_year))
{
int j = 0;
this.comNd.ItemsSource = years;
for (int i = 0; i < years.Count; i++)
{
if (m_year == years)
{
j = i;
break;
}
}
try
{
comNd.SelectedIndex = j;
}
catch { }
}
else
{
years.Add(m_year);
int j = 0;
this.comNd.ItemsSource = years;
for (int i = 0; i < years.Count; i++)
{
if (m_year == years)
{
j = i;
break;
}
}
try
{
comNd.SelectedIndex = j;
}
catch { }
}
Search();
//this.comNd.DisplayMemberPath = "RName";
//this.comNd.SelectedValuePath = "RCode";
}
}
LHToolButton SBBut = new LHToolButton();
LHToolButton QXSBBut = new LHToolButton();
private void ButLoad()
{
//新按钮-查询
LHToolButton SEARCHBut = new LHToolButton();
SEARCHBut.ToolClickEvent += SEARCHBut_ToolClickEvent;
SEARCHBut.ButStyle = "F";
SEARCHBut.Width = 70;
SEARCHBut.ButText = "查询";
sp.Children.Add(SEARCHBut);
LHToolButton CopyBut = new LHToolButton();
CopyBut.ToolClickEvent += CopyBut_ToolClickEvent;
CopyBut.ButStyle = "A";
CopyBut.Width = 70;
CopyBut.ButText = "复制";
sp.Children.Add(CopyBut);
LHToolButton SAVEBut = new LHToolButton();
SAVEBut.ToolClickEvent += SAVEBut_ToolClickEvent;
SAVEBut.ButStyle = "S";
SAVEBut.Width = 70;
SAVEBut.ButText = "保存";
sp.Children.Add(SAVEBut);
//LHToolButton SBBut = new LHToolButton();
SBBut.ToolClickEvent += SBBut_ToolClickEvent;
SBBut.ButStyle = "S";
SBBut.Width = 70;
SBBut.ButText = "上报";
sp.Children.Add(SBBut);
//LHToolButton QXSBBut = new LHToolButton();
QXSBBut.ToolClickEvent += QXSBBut_ToolClickEvent;
QXSBBut.ButStyle = "S";
QXSBBut.ButText = "取消上报";
QXSBBut.Margin = new Thickness(0, 0, 15, 0);
sp.Children.Add(QXSBBut);
//SBBut.IsEnabled = false;
//QXSBBut.IsEnabled = false;
}
private void SEARCHBut_ToolClickEvent(object sender, EventArgs e)
{
Search();
}
private void Search()
{
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("nd", comNd.SelectedValue == null ? "" : comNd.SelectedValue.ToString());
d.Add("dw", LHCurrentState.SystemUnit.Departcode);
d.Add("bb", comBB.SelectedItem == null ? "" : (comBB.SelectedItem as ClsRPTD_BUDGET_VERSION).Bbh);
d.Add("lx", 0 + "");
LHSysDB<string, Dictionary<string, Object>> dbl = new LHSysDB<string, Dictionary<string, Object>>();
dbl.InteractionMeans("ZxfGetAllandStatus", d, new InteractionCallback<Dictionary<string, Object>>(ResultLoadGrid2));
}
private bool flag = false;
private string stu = "";
private void ResultLoadGrid2(PostResultData<Dictionary<string, object>> obj, object state)
{
if (obj.Result != null)
{
string s = LHSerializationJson.GetDeserializeObject<string>(obj.Result["status"].ToString());
// 1-上报 2-通过 3-退回
if (String.IsNullOrWhiteSpace(s) || s == TH_STATUS)
{
flag = false;
}
else
{
//status =obj.Result["status"].ToString();
flag = true;
}
stu = s;
sp2.Visibility = Visibility.Visible;
switch (stu)
{
case SB_STATUS:
StatusTxt.Text = "已上报";
break;
case TG_STATUS:
StatusTxt.Text = "通过";
break;
case TH_STATUS:
StatusTxt.Text = "退回";
break;
default:
StatusTxt.Text = "";
break;
}
string o = obj.Result["list"].ToString();
if (LHSerializationJson.GetDeserializeObject<List<ClsRPTD_Budget_Zxf>>(o) != null)
{
List<ClsRPTD_Budget_Zxf> YsInfo = LHSerializationJson.GetDeserializeObject<List<ClsRPTD_Budget_Zxf>>(o);
InitGrid(YsInfo);
}
}
}
private void InitGrid(List<ClsRPTD_Budget_Zxf> YsInfo)
{
lHFlexExGrid1.Rows.Clear();
if (YsInfo == null || YsInfo.Count == 0)
{
return;
}
try
{
//SetHB(rows, cols);
int rows = YsInfo.Count ;
int cols = 6;
InitTableSize(new CellRange(0, 0, rows, cols));
SetHInfo(YsInfo);
//合并标题
//TitleHB(rows, cols);
SetData(YsInfo);
this.SetHangGao(0, 30.0);
this.SetTableLine(new CellRange(0, 0, rows, cols), new Thickness(1.0, 1.0, 1.0, 1.0));
//只读
setReadonly();
////大于表数头再冻结
if (lHFlexExGrid1.Rows.Count > 1)
{
lHFlexExGrid1.SetDongjie(new CellRange(1, 1));
}
SetColumnsWidth();
setJuZhong();
}
catch (Exception ex)
{
//Sys.Alert(ex.ToString());
}
}
private void ResultLoadGrid(PostResultData<List<ClsRPTD_Budget_Zxf>> obj, object state)
{
List<ClsRPTD_Budget_Zxf> YsInfo = obj.Result;
flag = false;
StatusTxt.Text = "";
InitGrid(YsInfo);
}
private void setReadonly()
{
//int[] cc1 = { 0, 1, 2, 6, 11, 12, 16, 21, 22, 26, 31, 32, 36, 41, 42, 46, 51, 52, 56 };
if (flag == true)
{
lHFlexExGrid1.IsReadOnly = true;
//SBBut.IsEnabled = false;
//QXSBBut.IsEnabled = true;
}
else
{
if(Status=="luru")
{
lHFlexExGrid1.IsReadOnly = false;
lHFlexExGrid1.Rows[1].IsReadOnly = true;
lHFlexExGrid1.Columns[0].IsReadOnly = true;
lHFlexExGrid1.Columns[5].IsReadOnly = false;
lHFlexExGrid1.Columns[6].IsReadOnly = false;
lHFlexExGrid1.Rows[0].IsReadOnly = true;
}
else if (Status=="check")
{
lHFlexExGrid1.IsReadOnly = false;
lHFlexExGrid1.Rows[0].IsReadOnly = true;
lHFlexExGrid1.Rows[1].IsReadOnly = true;
lHFlexExGrid1.Columns[0].IsReadOnly = true;
lHFlexExGrid1.Columns[1].IsReadOnly = true;
lHFlexExGrid1.Columns[3].IsReadOnly = true;
lHFlexExGrid1.Columns[4].IsReadOnly = true;
lHFlexExGrid1.Columns[5].IsReadOnly = true;
lHFlexExGrid1.Columns[6].IsReadOnly = true;
//lHFlexExGrid1.Rows[0].IsReadOnly = true;
}
}
}
/// <summary>
/// 设置居中
/// </summary>
private void setJuZhong()
{
for (int c = 0; c < lHFlexExGrid1.Columns.Count; c++)
{
lHFlexExGrid1.SetJuZhong(new CellRange(0, c), HorizontalAlignment.Center, VerticalAlignment.Center);
}
lHFlexExGrid1.SetJuZhong(new CellRange(1, 0), HorizontalAlignment.Center, VerticalAlignment.Center);
for (int c = 1; c < lHFlexExGrid1.Columns.Count; c++)
{
lHFlexExGrid1.SetJuZhong(new CellRange(1, c), HorizontalAlignment.Right, VerticalAlignment.Center);
}
for (int r = 2; r <lHFlexExGrid1.Rows.Count; r++)
{
for (int c = 1; c < lHFlexExGrid1.Columns.Count-1; c++)
{
lHFlexExGrid1.SetJuZhong(new CellRange(r, c), HorizontalAlignment.Right, VerticalAlignment.Center);
}
lHFlexExGrid1.SetJuZhong(new CellRange(r, 0), HorizontalAlignment.Left, VerticalAlignment.Center);
lHFlexExGrid1.SetJuZhong(new CellRange(r, lHFlexExGrid1.Columns.Count - 1), HorizontalAlignment.Left, VerticalAlignment.Center);
}
}
private void TitleHB(int rows, int cols)
{
//SetTableMerger(new CellRange(0, 0, 0, cols));//标题
//第一行
SetTableMerger(new CellRange(0, 0, 2, 0));
int i = 1;
while (i < cols + 1)
{
SetTableMerger(new CellRange(0, i, 0, i + 9));
i = i + 9 + 1;
}
//第二行
int j = 1;
while (j < cols + 1)
{
SetTableMerger(new CellRange(1, j, 2, j));
j = j + 1;
SetTableMerger(new CellRange(1, j, 1, j + 3));
j = j + 3 + 1;
SetTableMerger(new CellRange(1, j, 1, j + 3));
j = j + 3 + 1;
SetTableMerger(new CellRange(1, j, 2, j));
j = j + 1;
}
//this.SetTableMiddle(new CellRange(0, 0, 2, cols), "HSVS");
for (int k = 0; k <= cols; k++)
{
lHFlexExGrid1.Columns[k].HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
}
}
/// <summary>
/// 设置头信息
/// </summary>
private void SetHInfo(List<ClsRPTD_Budget_Zxf> p_Table)
{
//第一行
lHFlexExGrid1[0, 0] = "单位";
lHFlexExGrid1[0, 1] = "销售量";
lHFlexExGrid1[0, 2] = m_year + "年核定";
lHFlexExGrid1[0, 3] = m_year + "年上报";
lHFlexExGrid1[0, 4] = (Convert.ToInt32(m_year) - 1) + "年下达";
lHFlexExGrid1[0, 5] = (Convert.ToInt32(m_year) - 2) + "年下达";
lHFlexExGrid1[0, 6] = "备注";
}
private Dictionary<string, string> xmList = null;
/// <summary>
/// 设置数据详细
/// </summary>
private void SetData(List<ClsRPTD_Budget_Zxf> p_Table)
{
//lHFlexExGrid1.Columns[0].HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
//lHFlexExGrid1.Columns[1].HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
xmList = new Dictionary<string, string>();
int Index = 1;
foreach (ClsRPTD_Budget_Zxf item in p_Table)
{
lHFlexExGrid1[Index, 0] = item.Dwmc;
if (!xmList.ContainsKey(item.Dwmc))
{
xmList.Add(item.Dwmc, item.Dwbm);
}
lHFlexExGrid1[Index, 1] = item.Ssl;
lHFlexExGrid1[Index, 2] = item.Dnhd;
lHFlexExGrid1[Index, 3] = item.Dnsb;
lHFlexExGrid1[Index, 4] = item.Qunxd;
lHFlexExGrid1[Index, 5] = item.Qinxd;
lHFlexExGrid1[Index, 6] = item.Bz;
Index++;
}
if (Status == "luru")
{
lHFlexExGrid1.Columns[2].Visible = false;
}
else if (Status == "check")
{
lHFlexExGrid1.Columns[2].Visible = true;
}
}
/// <summary>
/// 定义区间
/// </summary>
private void InitTableSize(CellRange p_cellRange)
{
lHFlexExGrid1.ClearAllCell();
lHFlexExGrid1.SetSZCell(p_cellRange);
}
/// <summary>
/// 合并数据
/// </summary>
private void SetHB(int p_Row, int p_Col)
{
//SetTableMerger(new CellRange(0, 0, 0, p_Col));//标题
//SetTableMerger(new CellRange(1, 0, 2, 0));
int i = 1;
while (i < 33)
{
SetTableMerger(new CellRange(1, i, 1, i + 1));
i = i + 2;
}
//SetTableMerger(new CellRange(1, 1, 1, 2));
//SetTableMerger(new CellRange(1, 3, 1, 4));
//SetTableMerger(new CellRange(1, 5, 1, 6));
//SetTableMerger(new CellRange(1, 7, 1, 8));
//SetTableMerger(new CellRange(1, 9, 1, 10));
//SetTableMerger(new CellRange(1, 11, 1, 12));
//SetTableMerger(new CellRange(1, 13, 1, 14));
//SetTableMerger(new CellRange(1, 15, 1, 16));
//SetTableMerger(new CellRange(1, 17, 1, 18));
}
/// <summary>
/// 设置合并
/// </summary>
private void SetTableMerger(CellRange p_cellRange)
{
lHFlexExGrid1.SetHeBin(p_cellRange);
}
private void SetHangGao(int p_rowindex, double p_height)
{
lHFlexExGrid1.SetHangGao(p_rowindex, p_height);
}
/// <summary>
/// 设置区域字号
/// </summary>
/// <param name="p_cellRange"></param>
/// <param name="p_intSize"></param>
private void SetCellRangeSize(CellRange p_cellRange, int p_intSize)
{
lHFlexExGrid1.SetZiHao(p_cellRange, p_intSize);
}
/// <summary>
/// 设置边框
/// </summary>
private void SetTableLine(CellRange p_cellRange, Thickness p_thickness)
{
for (int intRow = p_cellRange.Row; intRow <= p_cellRange.Row2; intRow++)
{
for (int intCol = p_cellRange.Column; intCol <= p_cellRange.Column2; intCol++)
{
lHFlexExGrid1.SetHuaXian(new CellRange(intRow, intCol), p_thickness);
}
}
}
/// <summary>
/// 设置居中
/// </summary>
/// <param name="p_cellRange">设置区域</param>
/// <param name="p_strType">类型</param>
private void SetTableMiddle(CellRange p_cellRange, string p_strType)
{
HorizontalAlignment enumHorizontalAlignment = System.Windows.HorizontalAlignment.Center;
VerticalAlignment enumVerticalAlignment = System.Windows.VerticalAlignment.Center;
switch (p_strType)
{
case "HCVB":
enumVerticalAlignment = System.Windows.VerticalAlignment.Bottom;
break;
case "HCVS":
enumVerticalAlignment = System.Windows.VerticalAlignment.Stretch;
break;
case "HCVT":
enumVerticalAlignment = System.Windows.VerticalAlignment.Top;
break;
case "HLVB":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Left;
enumVerticalAlignment = System.Windows.VerticalAlignment.Bottom;
break;
case "HLVS":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Left;
enumVerticalAlignment = System.Windows.VerticalAlignment.Stretch;
break;
case "HLVT":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Left;
enumVerticalAlignment = System.Windows.VerticalAlignment.Top;
break;
case "HLVC":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Left;
break;
case "HRVB":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Right;
enumVerticalAlignment = System.Windows.VerticalAlignment.Bottom;
break;
case "HRVS":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Right;
enumVerticalAlignment = System.Windows.VerticalAlignment.Stretch;
break;
case "HRVT":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Right;
enumVerticalAlignment = System.Windows.VerticalAlignment.Top;
break;
case "HRVC":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Right;
break;
case "HSVB":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
enumVerticalAlignment = System.Windows.VerticalAlignment.Bottom;
break;
case "HSVS":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
enumVerticalAlignment = System.Windows.VerticalAlignment.Stretch;
break;
case "HSVT":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
enumVerticalAlignment = System.Windows.VerticalAlignment.Top;
break;
case "HSVC":
enumHorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
break;
}
for (int intRow = p_cellRange.Row; intRow <= p_cellRange.Row2; intRow++)
{
for (int intCol = p_cellRange.Column; intCol <= p_cellRange.Column2; intCol++)
{
lHFlexExGrid1.SetJuZhong(new CellRange(intRow, intCol), enumHorizontalAlignment, enumVerticalAlignment);
}
}
}
/// <summary>
/// 设置列宽
/// </summary>
private void SetColumnsWidth()
{
double widthFour = 100;
double widthThree = 200;
double widthFive = 250;
double widthTwo = 60;
double widthOne = 150;
int rows = lHFlexExGrid1.Rows.Count - 1;
//列宽度
lHFlexExGrid1.Columns[0].Width = new GridLength(widthFive);
lHFlexExGrid1.Columns[lHFlexExGrid1.Columns.Count - 1].Width = new GridLength(300);
for (int i = 1; i < lHFlexExGrid1.Columns.Count-1;i++ )
{
lHFlexExGrid1.Columns.Width = new GridLength(widthFour);
}
/* for (int i = 1; i < 24; i++)
{
SetTableMiddle(new CellRange(3, i, rows, i), "HRVC");
}
* */
}
Dictionary<string, int> ds = new Dictionary<string, int>();
private void lHFlexExGrid1_CellEditEnded(object sender, CellEditEventArgs e)
{
int col=e.Column;
if (col >=lHFlexExGrid1.Columns.Count-1)
{
return;
}
decimal su = 0;
for (int i = 2; i < lHFlexExGrid1.Rows.Count;i++ )
{
decimal rr = 0;
try
{
rr = Convert.ToDecimal(lHFlexExGrid1[i, col]);
}
catch
{
rr = 0;
}
su += rr;
}
lHFlexExGrid1[1,col] = su;
}
/// <summary>
/// 后去单元格数据
/// </summary>
/// <param name="p_lhGrid"></param>
/// <param name="p_Row"></param>
/// <param name="p_Col"></param>
/// <returns></returns>
private double GridCellValue(LHFlexExGrid p_lhGrid, int p_Row, int p_Col)
{
double doubValue = 0;
if (p_lhGrid.Cells[p_Row, p_Col] != null)
{
string strValue = p_lhGrid[p_Row, p_Col].ToString().Trim();
if (strValue != "")
{
doubValue = double.Parse(strValue);
}
}
return doubValue;
}
public void CreateReportStruct()
{
lHFlexExGrid1.Rows.Clear();
lHFlexExGrid1.Columns.Clear();
for (int r = 0; r < 26; r++)
{
lHFlexExGrid1.Rows.Add(new ClsRow());
}
for (int c = 0; c < 7; c++)
{
lHFlexExGrid1.Columns.Add(new Column());
}
}
#region
//设置样式
public void SetReportStyle()
{
//画线 居中
int rowCount = lHFlexExGrid1.Rows.Count;
int colCount = lHFlexExGrid1.Columns.Count;
for (int r = 2; r < rowCount; r++)
{
for (int c = 0; c < colCount; c++)
{
if (c == 1 && r > 2)
{
lHFlexExGrid1.SetHuaXian(new CellRange(r, c), new Thickness(1));
lHFlexExGrid1.SetJuZhong(new CellRange(r, c), HorizontalAlignment.Left, VerticalAlignment.Center);
}
else
{
lHFlexExGrid1.SetHuaXian(new CellRange(r, c), new Thickness(1));
lHFlexExGrid1.SetJuZhong(new CellRange(r, c), HorizontalAlignment.Center, VerticalAlignment.Center);
}
}
}
//计量单位
lHFlexExGrid1.SetJuZhong(new CellRange(1, 4), HorizontalAlignment.Right, VerticalAlignment.Center);
double widthOne = 50;
double widthTwo = 110;
double widthThree = 150;
//列宽度
lHFlexExGrid1.Columns[0].Width = new GridLength(widthOne);
lHFlexExGrid1.Columns[1].Width = new GridLength(widthThree);
lHFlexExGrid1.Columns[2].Width = new GridLength(widthThree);
lHFlexExGrid1.Columns[3].Width = new GridLength(widthThree);
lHFlexExGrid1.Columns[4].Width = new GridLength(widthTwo);
lHFlexExGrid1.Columns[5].Width = new GridLength(widthTwo);
lHFlexExGrid1.Columns[6].Width = new GridLength(widthThree);
//标题字号
lHFlexExGrid1.SetJuZhong(new CellRange(0, 0), HorizontalAlignment.Center, VerticalAlignment.Center);
lHFlexExGrid1.SetZiHao(new CellRange(0, 0), 20);
lHFlexExGrid1.SetCellStyle(new CellRange(0, 0), "FontWeight", FontWeights.Bold);
lHFlexExGrid1.Rows[0].Height = 50;
//只读
lHFlexExGrid1.Rows[0].IsReadOnly = true;
lHFlexExGrid1.Rows[1].IsReadOnly = true;
lHFlexExGrid1.Rows[2].IsReadOnly = true;
lHFlexExGrid1.Columns[0].IsReadOnly = true;
lHFlexExGrid1.Columns[1].IsReadOnly = true;
lHFlexExGrid1.Columns[2].IsReadOnly = true;
lHFlexExGrid1.Columns[3].IsReadOnly = true;
}
#endregion
private void SAVEBut_ToolClickEvent(object sender, EventArgs e)
{
List<ClsRPTD_Budget_Zxf> List = new List<ClsRPTD_Budget_Zxf>();
for (int i = 1; i < lHFlexExGrid1.Rows.Count; i++)
{
ClsRPTD_Budget_Zxf tb = new ClsRPTD_Budget_Zxf();
tb.Nd = comNd.SelectedValue.ToString();
tb.Dwmc = getData(lHFlexExGrid1[i, 0]);
tb.Dwbm = xmList == null ? "" : xmList[tb.Dwmc];
tb.Bbh = (comBB.SelectedItem as ClsRPTD_BUDGET_VERSION).Bbh;
tb.Ssl = getData(lHFlexExGrid1[i, 1]);
tb.Dnhd = getData(lHFlexExGrid1[i, 2]);
tb.Dnsb = getData(lHFlexExGrid1[i, 3]);
tb.Qunxd = getData(lHFlexExGrid1[i, 4]);
tb.Qinxd = getData(lHFlexExGrid1[i, 5]);
tb.Sbdwbm = LHCurrentState.SystemUnit.Departcode;
tb.Sbdwmc = LHCurrentState.SystemUnit.Departname;
tb.Bz = getData(lHFlexExGrid1[i, 6]);
List.Add(tb);
}
LHSysDB<List<ClsRPTD_Budget_Zxf>, ResultMessage> dbTool = new LHSysDB<List<ClsRPTD_Budget_Zxf>, ResultMessage>();
dbTool.InteractionMeans("RPTD_Budget_ZxfIns", List, new InteractionCallback<ResultMessage>(ResultBudget_ZxlIns));
}
private void ResultBudget_ZxlIns(PostResultData<ResultMessage> obj, object state)
{
if (obj.Result != null && obj.Result.Result == 1)
{
LHMessage.Show("保存成功!", MessageBoxExecutionResults.Success);
//Search();
}
else
{
LHMessage.Show("保存失败!", MessageBoxExecutionResults.Fail);
}
}
private string getData(Object o)
{
string s = "";
try
{
s = o.ToString();
}
catch
{
s = "";
}
return s;
}
private void comNd_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
m_year =comNd.SelectedValue==null?"": comNd.SelectedValue.ToString();
List<ClsRPTD_BUDGET_VERSION> bbs = YsBbs.Where(o => o.Nd == comNd.SelectedValue.ToString()).OrderByDescending(o => o.Bbh).ToList();
comBB.ItemsSource = bbs;
this.comBB.DisplayMemberPath = "Bbh";
this.comBB.SelectedValuePath = "Bbh";
comBB.SelectedIndex = 0;
}
private void CopyBut_ToolClickEvent(object sender, EventArgs e)
{
if ("1" == (comBB.SelectedItem as ClsRPTD_BUDGET_VERSION).Bbh)
{
LHMessage.Show("无低版本预算数据!", MessageBoxExecutionResults.Warning);
return;
}
//上一个版本号
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("nd", comNd.SelectedValue.ToString());
d.Add("dw", LHCurrentState.SystemUnit.Departcode);
d.Add("bb", (comBB.SelectedItem as ClsRPTD_BUDGET_VERSION).Bbh);
LHSysDB<string, string> dbl = new LHSysDB<string, string>();
dbl.InteractionMeans("RPTD_ZxfPreVersion", d, new InteractionCallback<string>(ResultPreVersion));
}
private void ResultPreVersion(PostResultData<string> obj, object state)
{
//上一个版本
string bb = obj.Result;
ClsRPTD_Budget_Zxf tb = new ClsRPTD_Budget_Zxf();
tb.Nd = comNd.SelectedValue.ToString();
tb.Sbdwbm = LHCurrentState.SystemUnit.Departcode;
tb.Bbh = bb;
LHSysDB<string, List<ClsRPTD_Budget_Zxf>> dbl = new LHSysDB<string, List<ClsRPTD_Budget_Zxf>>();
dbl.InteractionMeans("RPTD_Budget_ZxfLoad", tb, new InteractionCallback<List<ClsRPTD_Budget_Zxf>>(ResultLoadGrid));
//LHSysDB<string, Dictionary<string, Object>> dbl = new LHSysDB<string, Dictionary<string, Object>>();
//dbl.InteractionMeans("BasicGetAllandStatus", tb, new InteractionCallback<Dictionary<string, Object>>(ResultLoadGrid2));
}
private void SBBut_ToolClickEvent(object sender, EventArgs e)
{
if (stu == SB_STATUS)
{
LHMessage.Show("上报状态中,不允许重复上报!", MessageBoxExecutionResults.Warning);
return;
}
if (stu == TG_STATUS)
{
LHMessage.Show("上报已通过,无法重复上报!", MessageBoxExecutionResults.Warning);
return;
}
if (stu == TH_STATUS)
{
ClsRPTD_Budget_Status czd = new ClsRPTD_Budget_Status();
czd.Nd = comNd.SelectedValue.ToString();
czd.Dwbm = LHCurrentState.SystemUnit.Departcode;
czd.Dwmc = LHCurrentState.SystemUnit.Departname;
czd.Bbh = (comBB.SelectedItem as ClsRPTD_BUDGET_VERSION).Bbh;
czd.Status = "1";
czd.Sbr = LHCurrentState.SystemUser.Userid;
czd.Sbfylx = "7";
//czd.Sbsj = LHCurrentState.SystemTime.DateCode;
LHSysDB<ClsRPTD_Budget_Status, ResultMessage> dbl = new LHSysDB<ClsRPTD_Budget_Status, ResultMessage>();
dbl.InteractionMeans("RPTD_StatusUpd", czd, new InteractionCallback<ResultMessage>(ResultRPTD_SB), czd);
}
else
{
//初始状态
ClsRPTD_Budget_Status czd = new ClsRPTD_Budget_Status();
czd.Nd = comNd.SelectedValue.ToString();
czd.Dwbm = LHCurrentState.SystemUnit.Departcode;
czd.Dwmc = LHCurrentState.SystemUnit.Departname;
czd.Bbh = (comBB.SelectedItem as ClsRPTD_BUDGET_VERSION).Bbh;
czd.Status = "1";
czd.Sbr = LHCurrentState.SystemUser.Userid;
czd.Sbfylx = "7";
//czd.Sbsj = LHCurrentState.SystemTime.DateCode;
LHSysDB<ClsRPTD_Budget_Status, ResultMessage> dbl = new LHSysDB<ClsRPTD_Budget_Status, ResultMessage>();
dbl.InteractionMeans("RPTD_Budget_StatusAdd", czd, new InteractionCallback<ResultMessage>(ResultRPTD_SB), czd);
}
}
private void ResultRPTD_SB(PostResultData<ResultMessage> obj, object state)
{
if (obj.Result != null && obj.Result.Result == 1)
{
LHMessage.Show("上报成功!", MessageBoxExecutionResults.Success);
Search();
}
else
{
LHMessage.Show("上报失败!", MessageBoxExecutionResults.Fail);
}
}
private void QXSBBut_ToolClickEvent(object sender, EventArgs e)
{
if (stu == TG_STATUS)
{
LHMessage.Show("预算已审批通过,无法取消上报!", MessageBoxExecutionResults.Warning);
return;
}
if (stu == TH_STATUS)
{
LHMessage.Show("取消上报成功!", MessageBoxExecutionResults.Success);
return;
}
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("nd", comNd.SelectedValue.ToString());
d.Add("dw", LHCurrentState.SystemUnit.Departcode);
d.Add("bb", (comBB.SelectedItem as ClsRPTD_BUDGET_VERSION).Bbh);
d.Add("lx", "7");
LHSysDB<string, ResultMessage> dbl = new LHSysDB<string, ResultMessage>();
dbl.InteractionMeans("RPTD_Budget_StatusQxsb", d, new InteractionCallback<ResultMessage>(ResultQxsb));
}
private void ResultQxsb(PostResultData<ResultMessage> obj, object state)
{
if (obj.Result != null && obj.Result.Result == 1)
{
LHMessage.Show("取消上报成功!", MessageBoxExecutionResults.Success);
Search();
}
}
}
}
|