tijian_jichuang/Code/SaleSettings/frmTuanJianQingKuangChaXun.cs
2025-02-20 11:54:48 +08:00

207 lines
9.3 KiB
C#

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 SOH.Kernel;
using EAS.Services;
using SOH.BLL;
using SOH.Entities;
using xiaoy.Excel;
using SOH.Common;
namespace SOH.SaleSettings
{
[ModuleAttribute(ModuleID = "FBFE14A5-7652-4A53-B356-6DD2AF21544B", ModuleName = "团检情况查询")]
public partial class frmTuanJianQingKuangChaXun : SOH.Window.baseChildForm
{
public frmTuanJianQingKuangChaXun()
{
InitializeComponent();
}
DataTable dts1;
DataTable lt;
System.Windows.Forms.SortOrder order;
private void frmTuanJianQingKuangChaXun_Load(object sender, EventArgs e)
{
dataGridView1.AutoGenerateColumns = false;
order = System.Windows.Forms.SortOrder.Ascending;
dataGridView1.Columns[12].HeaderCell.SortGlyphDirection = order;
var service = ServiceContainer.GetService<It_ht>();
//var service1 = ServiceContainer.GetService<It_ttgzb>();
//lt = Newtonsoft.Json.JsonConvert.DeserializeObject(service1.GetListAll2(), typeof(DataTable)) as DataTable;
if (SOH.LoginUser.yydm == "1")
{
//thtBindingSource.DataSource = service.GetListByxsy(SOH.LoginUser.xm, "");
//dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsy2(SOH.LoginUser.xm, ""), typeof(DataTable));
//dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsyWjrs(SOH.LoginUser.xm, ""), typeof(DataTable));
dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsyWjrs("", ""), typeof(DataTable));
}
else
{
//thtBindingSource.DataSource = service.GetListByxsy("", "");
//dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsy2("", ""), typeof(DataTable));
dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsyWjrs("", ""), typeof(DataTable));
}
}
private void tbSelect_TextChanged(object sender, EventArgs e)
{
var service = ServiceContainer.GetService<It_ht>();
if (SOH.LoginUser.yydm == "1")
{
//thtBindingSource.DataSource = service.GetListByxsy(SOH.LoginUser.xm, this.tbSelect.Text);
//dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsy2(SOH.LoginUser.xm, this.tbSelect.Text), typeof(DataTable));
dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsyWjrs(SOH.LoginUser.xm, this.tbSelect.Text), typeof(DataTable));
}
else
{
//thtBindingSource.DataSource = service.GetListByxsy("", this.tbSelect.Text);
//dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsy2("", this.tbSelect.Text), typeof(DataTable));
dataGridView1.DataSource = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListByxsyWjrs("", this.tbSelect.Text), typeof(DataTable));
}
}
private void dataGridView1_DoubleClick(object sender, EventArgs e)
{
frmTuanJianzhiXingQingKuangChaXun t = new frmTuanJianzhiXingQingKuangChaXun(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["合同编码"].Value));
t.ShowDialog();
}
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
//int htbm = Convert.ToInt32(dataGridView1.Rows[e.ColumnIndex].Cells["htbmDataGridViewTextBoxColumn"].Value);
//var service = ServiceContainer.GetService<It_ttgzb>();
//int htpjzlzs = 0; //合同平均折率总数
//double fzhjs = 0;//分组合计
//if (rsxj.Index == e.ColumnIndex)
//{
// e.Value= service.GetList(htbm, "").Count.ToString();
//}
//if (htpjzl.Index == e.ColumnIndex)
//{
// DataTable dt22 = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListtj(htbm), typeof(DataTable)) as DataTable;
// for (int i = 0; i < dt22.Rows.Count; i++)
// {
// htpjzlzs += Convert.ToInt32(dt22.Rows[i]["折率"]);
// }
// e.Value= (htpjzlzs / dt22.Rows.Count).ToString() + "%";
//}
//if (fzhj.Index == e.ColumnIndex)
//{
// DataTable dt33 = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListtj(htbm), typeof(DataTable)) as DataTable;
// for (int i = 0; i < dt33.Rows.Count; i++)
// {
// fzhjs += Convert.ToDouble(dt33.Rows[i]["实检金额"]);
// }
// e.Value= fzhjs.ToString("0.00");
//}
}
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
/* if (SOH.LoginUser.yydm == "1")
{
int htbm = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["合同编码"].Value);
int wjrs = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["wjrs"].Value);
if (wjrs == 0)
{
dataGridView1.Rows[e.RowIndex].Cells["wjje"].Value = "0";
}
else
{
var service = ServiceContainer.GetService<It_ttgzb>();
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListtjAll2(htbm), typeof(DataTable)) as DataTable;
dataGridView1.Rows[e.RowIndex].Cells["wjje"].Value = Convert.ToDouble(dt.Rows[0]["sjje"]);
}
}*/
//int htbm = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["htbmDataGridViewTextBoxColumn"].Value);
//var service = ServiceContainer.GetService<It_ttgzb>();
//int htpjzlzs = 0; //合同平均折率总数
//double fzhjs = 0;//分组合计
//dts1 = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListtjAll(htbm), typeof(DataTable)) as DataTable;
////dataGridView1.Rows[e.RowIndex].Cells["rsxj"].Value = lt.Where(t => t.htbm == htbm).Count().ToString();
//dataGridView1.Rows[e.RowIndex].Cells["rsxj"].Value = lt.Select("htbm=" + htbm).Count();
////var rows = dts1.Select("htbm="+htbm);
//if (dts1.Rows.Count>0)
//{
// foreach (DataRow row in dts1.Rows)
// {
// htpjzlzs += Convert.ToInt32(row["折率"]);
// fzhjs += Convert.ToDouble(row["实检金额"]);
// }
// dataGridView1.Rows[e.RowIndex].Cells["htpjzl"].Value = (htpjzlzs / dts1.Rows.Count).ToString() + "%";
// dataGridView1.Rows[e.RowIndex].Cells["fzhj"].Value = fzhjs.ToString("0.00");
//}
}
private void dataGridView1_Click(object sender, EventArgs e)
{
//int htbm = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["htbmDataGridViewTextBoxColumn"].Value);
//var service = ServiceContainer.GetService<It_ttgzb>();
//int htpjzlzs = 0; //合同平均折率总数
//double fzhjs = 0;//分组合计
//if (rsxj.Index == dataGridView1.CurrentRow.Index)
//{
// e.Value = service.GetList(htbm, "").Count.ToString();
//}
//if (htpjzl.Index == e.ColumnIndex)
//{
// DataTable dt22 = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListtj(htbm), typeof(DataTable)) as DataTable;
// for (int i = 0; i < dt22.Rows.Count; i++)
// {
// htpjzlzs += Convert.ToInt32(dt22.Rows[i]["折率"]);
// }
// e.Value = (htpjzlzs / dt22.Rows.Count).ToString() + "%";
//}
//if (fzhj.Index == e.ColumnIndex)
//{
// DataTable dt33 = Newtonsoft.Json.JsonConvert.DeserializeObject(service.GetListtj(htbm), typeof(DataTable)) as DataTable;
// for (int i = 0; i < dt33.Rows.Count; i++)
// {
// fzhjs += Convert.ToDouble(dt33.Rows[i]["实检金额"]);
// }
// e.Value = fzhjs.ToString("0.00");
//}
}
private void button1_Click(object sender, EventArgs e)
{
new ExcelDC().ExportExcel("团检客户列表", this.dataGridView1);
}
private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex == 12)
{
if (this.dataGridView1.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == System.Windows.Forms.SortOrder.Ascending)
{
order = System.Windows.Forms.SortOrder.Descending;
}
}
}
}
}