📄 frmselectdatetime.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace EMS.SelectDataDialog
{
public partial class frmSelectDateTime : Form
{
BaseClass.BaseInfo baseinfo = new EMS.BaseClass.BaseInfo();
BuyStock.frmCurrentAccountBook currentAccountBook = new EMS.BuyStock.frmCurrentAccountBook();
public string G_Str_tradeCode = "";
public string G_Str_fullName = "";
public int G_Int_rows = 0;
public int G_Int_CurrrentRows = 0;
int G_Int_JH = 0;
public string M_Str_units = "";
public string M_Str_object = "";
string[] G_AStr_Temp = new string[5];
public frmSelectDateTime()
{
InitializeComponent();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
if (M_Str_object == "Detailed")
{
SaleStock.frmSellStockDetailed sellDetailed = new EMS.SaleStock.frmSellStockDetailed();
DataSet ds = null;
ds = baseinfo.SellStockDetailed(G_Str_tradeCode, dtpStar.Value, dtpEnd.Value, "tb_sell_detailed");
sellDetailed.dgvSaleStockList.DataSource = ds.Tables[0].DefaultView;
ds = baseinfo.SellStockDetailed(G_Str_tradeCode, dtpStar.Value, dtpEnd.Value, "tb_resell_detailed");
sellDetailed.dgvResellStockList.DataSource = ds.Tables[0].DefaultView;
sellDetailed.Text = "明细账本--商品:" + G_Str_fullName + " 日期:【" + dtpStar.Value.ToString() + "】至【" + dtpEnd.Value.ToString() + "】";
sellDetailed.ShowDialog();
}
else
{
DataSet ds = null;
DataSet ds_main = null;
DataSet ds_Detailed = null;
string P_Str_Code = "";
ds=baseinfo.FindCurrentAccountDate(M_Str_units,dtpStar.Value,dtpEnd.Value);
//设置表格列
currentAccountBook.dgvCurrentAccountList.ColumnCount = 7;
currentAccountBook.dgvCurrentAccountList.Columns[0].HeaderText = "日期";
currentAccountBook.dgvCurrentAccountList.Columns[0].Width = 75;
currentAccountBook.dgvCurrentAccountList.Columns[1].HeaderText = "单据编号";
currentAccountBook.dgvCurrentAccountList.Columns[1].Width = 125;
currentAccountBook.dgvCurrentAccountList.Columns[2].HeaderText = "摘要";
currentAccountBook.dgvCurrentAccountList.Columns[2].Width = 260;
currentAccountBook.dgvCurrentAccountList.Columns[3].HeaderText = "应收增加";
currentAccountBook.dgvCurrentAccountList.Columns[3].Width = 80;
currentAccountBook.dgvCurrentAccountList.Columns[4].HeaderText = "实际增加";
currentAccountBook.dgvCurrentAccountList.Columns[4].Width = 80;
currentAccountBook.dgvCurrentAccountList.Columns[5].HeaderText = "应收减少";
currentAccountBook.dgvCurrentAccountList.Columns[5].Width = 80;
currentAccountBook.dgvCurrentAccountList.Columns[6].HeaderText = "实际减少";
currentAccountBook.dgvCurrentAccountList.Columns[6].Width = 80;
if (ds.Tables[0].Rows.Count > 0) //存在往来关系
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
//识别--货物状态
P_Str_Code = ds.Tables[0].Rows[i]["billCode"].ToString().Substring(8, 4);
if (P_Str_Code.Substring(0, 2) == "JH" && P_Str_Code!="JHTH")
{
ds_Detailed = baseinfo.FindDetailde("tb_warehouse_detailed", ds.Tables[0].Rows[i]["billcode"].ToString());
ds_main = baseinfo.FindMain("tb_warehouse_main", ds.Tables[0].Rows[i]["billcode"].ToString());
//动态设置表格行数(注意:每当增加一些新表格的时,原有表格中最后一行数据,DataGridView控件将其自动清空)
G_Int_rows = G_Int_rows + ds_Detailed.Tables[0].Rows.Count;
currentAccountBook.dgvCurrentAccountList.RowCount = G_Int_rows;
//动态创建新表格后,填充-自动清空的行数据
try
{ //当表格中没有数据时,作出异常处理.
currentAccountBook.dgvCurrentAccountList[0, G_Int_JH].Value = G_AStr_Temp[0].ToString();
currentAccountBook.dgvCurrentAccountList[1, G_Int_JH].Value = G_AStr_Temp[1].ToString();
currentAccountBook.dgvCurrentAccountList[2, G_Int_JH].Value = G_AStr_Temp[2].ToString();
currentAccountBook.dgvCurrentAccountList[5, G_Int_JH].Value = G_AStr_Temp[3].ToString();
currentAccountBook.dgvCurrentAccountList[6, G_Int_JH].Value = G_AStr_Temp[4].ToString();
}
catch { }
G_Int_CurrrentRows = currentAccountBook.dgvCurrentAccountList.RowCount - ds_Detailed.Tables[0].Rows.Count;
for (int jh = G_Int_CurrrentRows; jh < ds_Detailed.Tables[0].Rows.Count + G_Int_CurrrentRows; jh++)
{
currentAccountBook.dgvCurrentAccountList[0, jh].Value = ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["billdate"].ToString().Substring(0, 10);
currentAccountBook.dgvCurrentAccountList[1, jh].Value = ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["billcode"].ToString();
currentAccountBook.dgvCurrentAccountList[2, jh].Value = "进货:" + ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["fullname"].ToString() + ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["qty"].ToString() + "*" + ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["price"].ToString() + ":" + ds_main.Tables[0].Rows[0]["handle"].ToString();
currentAccountBook.dgvCurrentAccountList[5, jh].Value = ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["tsum"].ToString();
currentAccountBook.dgvCurrentAccountList[6, jh].Value = ds_main.Tables[0].Rows[0]["payment"].ToString();
//当动态创建表格时,将表格中最后一行数据存储到数组中.
G_AStr_Temp[0] = currentAccountBook.dgvCurrentAccountList[0, jh].Value.ToString();
G_AStr_Temp[1] = currentAccountBook.dgvCurrentAccountList[1, jh].Value.ToString();
G_AStr_Temp[2] = currentAccountBook.dgvCurrentAccountList[2, jh].Value.ToString();
G_AStr_Temp[3] = currentAccountBook.dgvCurrentAccountList[5, jh].Value.ToString();
G_AStr_Temp[4] = currentAccountBook.dgvCurrentAccountList[6, jh].Value.ToString();
//记录最后一行记录
G_Int_JH = jh;
}
}
else if (P_Str_Code == "JHTH")
{
ds_Detailed = baseinfo.FindDetailde("tb_rewarehouse_detailed", ds.Tables[0].Rows[i]["billcode"].ToString());
ds_main = baseinfo.FindMain("tb_rewarehouse_main", ds.Tables[0].Rows[i]["billcode"].ToString());
//动态设置表格行数(注意:每当增加一些新表格的时,原有表格中最后一行数据,DataGridView控件将其自动清空)
G_Int_rows = G_Int_rows + ds_Detailed.Tables[0].Rows.Count;
currentAccountBook.dgvCurrentAccountList.RowCount = G_Int_rows;
//动态创建新表格后,填充-自动清空的行数据
try
{ //当表格中没有数据时,作出异常处理.
currentAccountBook.dgvCurrentAccountList[0, G_Int_JH].Value = G_AStr_Temp[0].ToString();
currentAccountBook.dgvCurrentAccountList[1, G_Int_JH].Value = G_AStr_Temp[1].ToString();
currentAccountBook.dgvCurrentAccountList[2, G_Int_JH].Value = G_AStr_Temp[2].ToString();
currentAccountBook.dgvCurrentAccountList[5, G_Int_JH].Value = G_AStr_Temp[3].ToString();
currentAccountBook.dgvCurrentAccountList[6, G_Int_JH].Value = G_AStr_Temp[4].ToString();
}
catch { }
G_Int_CurrrentRows = currentAccountBook.dgvCurrentAccountList.RowCount - ds_Detailed.Tables[0].Rows.Count;
for (int jh = G_Int_CurrrentRows; jh < ds_Detailed.Tables[0].Rows.Count + G_Int_CurrrentRows; jh++)
{
currentAccountBook.dgvCurrentAccountList[0, jh].Value = ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["billdate"].ToString().Substring(0, 10);
currentAccountBook.dgvCurrentAccountList[1, jh].Value = ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["billcode"].ToString();
currentAccountBook.dgvCurrentAccountList[2, jh].Value = "进货退货:" + ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["fullname"].ToString() + ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["qty"].ToString() + "*" + ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["price"].ToString() + ":" + ds_main.Tables[0].Rows[0]["handle"].ToString();
currentAccountBook.dgvCurrentAccountList[3, jh].Value = ds_Detailed.Tables[0].Rows[jh - G_Int_CurrrentRows]["tsum"].ToString();
currentAccountBook.dgvCurrentAccountList[4, jh].Value = ds_main.Tables[0].Rows[0]["gathering"].ToString();
//当动态创建表格时,将表格中最后一行数据存储到数组中.
G_AStr_Temp[0] = currentAccountBook.dgvCurrentAccountList[0, jh].Value.ToString();
G_AStr_Temp[1] = currentAccountBook.dgvCurrentAccountList[1, jh].Value.ToString();
G_AStr_Temp[2] = currentAccountBook.dgvCurrentAccountList[2, jh].Value.ToString();
G_AStr_Temp[3] = currentAccountBook.dgvCurrentAccountList[3, jh].Value.ToString();
G_AStr_Temp[4] = currentAccountBook.dgvCurrentAccountList[4, jh].Value.ToString();
//记录最后一行记录
G_Int_JH = jh;
}
}
else if (P_Str_Code.Substring(0, 2) == "XS"&& P_Str_Code!="XSTH")
{
ds_Detailed = baseinfo.FindDetailde("tb_sell_detailed", ds.Tables[0].Rows[i]["billcode"].ToString());
ds_main = baseinfo.FindMain("tb_sell_main", ds.Tables[0].Rows[i]["billcode"].ToString());
//动态设置表格行数(注意:每当增加一些新表格的时,原有表格中最后一行数据,DataGridView控件将其自动清空)
G_Int_rows = G_Int_rows + ds_Detailed.Tables[0].Rows.Count;
currentAccountBook.dgvCurrentAccountList.RowCount = G_Int_rows;
//动态创建新表格后,填充-自动清空的行数据
try
{ //当表格中没有数据时,作出异常处理.
currentAccountBook.dgvCurrentAccountList[0, G_Int_JH].Value = G_AStr_Temp[0].ToString();
currentAccountBook.dgvCurrentAccountList[1, G_Int_JH].Value = G_AStr_Temp[1].ToString();
currentAccountBook.dgvCurrentAccountList[2, G_Int_JH].Value = G_AStr_Temp[2].ToString();
currentAccountBook.dgvCurrentAccountList[3, G_Int_JH].Value = G_AStr_Temp[3].ToString();
currentAccountBook.dgvCurrentAccountList[4, G_Int_JH].Value = G_AStr_Temp[4].ToString();
}
catch { }
G_Int_CurrrentRows = currentAccountBook.dgvCurrentAccountList.RowCount - ds_Detailed.Tables[0].Rows.Count;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -