using LYFZ.ComponentLibrary;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LYFZ.Software.MainBusiness.MarketingAllPerson
{
public partial class TeamCompetitionFormMain : LYFZ.Software.UI.MarketingAllPerson.TeamCompetitionFormMain
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
public TeamCompetitionFormMain()
{
this.Load += TeamCompetitionFormMain_Load;
this.Shown += TeamCompetitionFormMain_Shown;
this.cmbtreevActivityName.ComboBoxTree_NodeMouseClick += cmbtreevActivityName_ComboBoxTree_NodeMouseClick;
this.cmbtreevMaxTeamName.ComboBoxTree_NodeMouseClick += cmbtreevMaxTeamName_ComboBoxTree_NodeMouseClick;
this.cmbtreevMinTeamName.ComboBoxTree_NodeMouseClick += cmbtreevMinTeamName_ComboBoxTree_NodeMouseClick;
this.chkYejiOrderBy.Click += chkYejiOrderBy_Click;
this.btnNewActivity.Click += btnNewActivity_Click;
this.btnSaveAs.Click += btnSaveAs_Click;
this.btnClose.Click += btnClose_Click;
this.pictImage.Click += pictImage_Click;
this.Resize += TeamCompetitionFormMain_Resize;
}
///
/// 主门市比重
///
decimal MinStoreProportion = 0;
///
/// 副门市比重
///
decimal ViceStoreProportion = 0;
///
/// 窗体加载事件
///
///
///
void TeamCompetitionFormMain_Load(object sender, EventArgs e)
{
DataTable dtProportion = orbll.GetView_Custom("tb_ErpCommissionPercentage", StrWhere: "Cp_ProportionType = 1", ShowColumnName: "Cp_ProportionCode,Cp_Proportion").Tables[0];
for (int i = 0; i < dtProportion.Rows.Count; i++)
{
switch (dtProportion.Rows[i]["Cp_ProportionCode"].ToString().Trim())
{
case "MainStoreProportion": MinStoreProportion = Convert.ToDecimal(dtProportion.Rows[i]["Cp_Proportion"]); break;
case "DeputyStoreProportion": ViceStoreProportion = Convert.ToDecimal(dtProportion.Rows[i]["Cp_Proportion"]); break;
}
}
}
///
/// 窗体加载事件
///
///
///
void TeamCompetitionFormMain_Shown(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName);
this.PublicFunctionRows();
bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.全员营销);
if (!b)
{
this.Close();
}
}
///
/// 活动名称选择事件
///
///
///
void cmbtreevActivityName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxTaskName(this.cmbtreevMaxTeamName, this.cmbtreevActivityName.Tag.ToString().Trim(), IsFirstNodeNull: true);
this.PublicFunctionRows();
}
///
/// 大队名称选择事件
///
///
///
void cmbtreevMaxTeamName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMinTaskName(this.cmbtreevMinTeamName, this.cmbtreevActivityName.Tag.ToString().Trim(), this.cmbtreevMaxTeamName.Tag.ToString().Trim(), IsFirstNodeNull: true);
this.PublicFunctionRows();
}
///
/// 小组名称选择事件
///
///
///
void cmbtreevMinTeamName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.PublicFunctionRows();
}
///
/// 按业绩排序
///
///
///
void chkYejiOrderBy_Click(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 新建活动
///
///
///
void btnNewActivity_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.MarketingAllPerson.SetSmallForm.AddTeamPersonSmallForm frm = new SetSmallForm.AddTeamPersonSmallForm();
frm.StartPosition = FormStartPosition.Manual;
frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
frm.ShowDialog();
if (frm.IsSaveed)
{ LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName); }
}
///
/// 另存为
///
///
///
void btnSaveAs_Click(object sender, EventArgs e)
{
string StrFilleName = "";
if (!string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{ StrFilleName += this.cmbtreevMinTeamName.Text.Trim() + "组PK图"; }
else if (!string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()))
{ StrFilleName += this.cmbtreevMaxTeamName.Text.Trim() + "队PK图"; }
else if (!string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim()))
{ StrFilleName += this.cmbtreevActivityName.Text.Trim() + "PK图"; }
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DownloadSaveAs(this.pictImage.Image, StrFilleName: StrFilleName);
}
///
/// 关闭
///
///
///
void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 图片点击获取焦点
///
///
///
void pictImage_Click(object sender, EventArgs e)
{
this.pictImage.Focus();
}
///
/// 窗体大小发生变事件
///
///
///
void TeamCompetitionFormMain_Resize(object sender, EventArgs e)
{
//this.panelEx3.Height = this.panelEx1.Height - this.panelEx2.Height - 6;
}
///
/// 绘制数据
///
void PublicFunctionRows()
{
if (!string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim()) && this.cmbtreevActivityName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevActivityName.Tag.ToString().Trim()))
{
string StrTasNumber = this.cmbtreevActivityName.Tag.ToString().Trim();
DataTable dtActive = orbll.GetView_Custom("tb_ErpTeamActiveSet", StrWhere: "Tas_Number = '" + StrTasNumber + "'", ShowColumnName: "Tas_DateTimeStart,Tas_DateTimeEnd,Tas_BaodiTask,Tas_TargetTask,Tas_SprintTask").Tables[0];
if (dtActive.Rows.Count > 0)
{
DataTable dtOpenSingle = OpenOrderPersonGroupDataTable(OpenOrderPersonDataTable(Convert.ToDateTime(dtActive.Rows[0]["Tas_DateTimeStart"]), Convert.ToDateTime(dtActive.Rows[0]["Tas_DateTimeEnd"])));
string StrWhere = "Where Tps_TasNumber = '" + StrTasNumber + "'";
if (this.cmbtreevMaxTeamName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Tag.ToString()))
{ StrWhere += " And Tps_TmxtNumber = '" + this.cmbtreevMaxTeamName.StrGetName.Trim() + "'"; }
if (this.cmbtreevMinTeamName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevMinTeamName.Tag.ToString()))
{ StrWhere += " And Tps_TmitNumber = '" + this.cmbtreevMinTeamName.StrGetName.Trim() + "'"; }
string ExecuteSql = "select Tps_TmxtNumber,Tps_TmitNumber,Tps_UserNumber,Tmxn_Name,Tmin_Name,User_Name,Tps_BaodiTask,Tps_TargetTask,Tps_SprintTask from tb_ErpTeamPersonSet Left Join tb_ErpUser on User_EmployeeID = Tps_UserNumber Left Join tb_ErpTeamMaxNameSet on Tmxn_Number = Tps_TmxnNumber Left Join tb_ErpTeamMinNameSet on Tmin_Number = Tps_TminNumber " + StrWhere + ";";
ExecuteSql += "select Tmxt_TasNumber,Tmxt_Number,Tmxn_Name,Tmxt_BaodiTask,Tmxt_TargetTask,Tmxt_SprintTask from tb_ErpTeamMaxTaskSet Left Join tb_ErpTeamMaxNameSet on Tmxn_Number = Tmxt_TmxnNumber where Tmxt_TasNumber = '" + StrTasNumber + "';";
ExecuteSql += "select Tmit_TmxtNumber,Tmit_Number,Tmin_Name,Tmit_BaodiTask,Tmit_TargetTask,Tmit_SprintTask from tb_ErpTeamMinTaskSet Left Join tb_ErpTeamMinNameSet on Tmin_Number = Tmit_TminNumber where Tmit_TasNumber = '" + StrTasNumber + "';";
DataSet dsData = orbll.GetView_Custom(ExecuteSql);
DataTable dtTeamPerson = TeamPersonRankedDataTable(dsData.Tables["ds"], dtOpenSingle);
DataTable dtTeamMax = dsData.Tables["ds1"];
DataTable dtTeamMin = dsData.Tables["ds2"];
#region 绘标题
int TopAdd = 5;
int LeftWidth = 0;
int RowHeight = 30;
Hashtable htColumnWidth = this.GetColumnWidth();
int newBmpWidth = 0;
for (int i = 0; i < dtTeamPerson.Columns.Count; i++)
{
switch (dtTeamPerson.Columns[i].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
break;
default:
if (!this.chkYejiOrderBy.Checked)
{
if (dtTeamPerson.Columns[i].ColumnName.Trim() == "大队名称")
{
if (!string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()) || !string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{ break; }
}
if (dtTeamPerson.Columns[i].ColumnName.Trim() == "小组名称")
{
if (!string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{ break; }
}
}
newBmpWidth += Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[i].ColumnName.Trim()].ToString());
break;
}
}
int newBmpHeight = RowHeight * dtTeamPerson.Rows.Count + 50;
if (!this.chkYejiOrderBy.Checked)
{
if (string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()))
{ newBmpHeight += RowHeight * dtTeamMax.Rows.Count; }
if (string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{ newBmpHeight += RowHeight * dtTeamMin.Rows.Count; }
}
if (newBmpHeight < (this.panelEx3.Height - 23))
{ newBmpHeight = (this.panelEx3.Height - 23); }
Bitmap newBmp = new Bitmap(newBmpWidth + LeftWidth * 2 + 10, newBmpHeight);
Graphics g = Graphics.FromImage(newBmp);
g.Clear(System.Drawing.Color.White);
Brush b = Brushes.Black;
Pen p = new Pen(Brushes.Black, 1);
Font ft11b = new Font("微软雅黑", 11);
Font ft11 = new Font("微软雅黑", 11, FontStyle.Italic);
Font ft15 = new Font("微软雅黑", 15);
int TableWidth = newBmp.Width - LeftWidth * 2 - 10;
Rectangle rec1 = new Rectangle(LeftWidth, 0, TableWidth, RowHeight);
g.FillRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.backColortitle, rec1);//画标题矩形
Rectangle rec = new Rectangle(LeftWidth, 0, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, rec);
int intForTitleLeft = rec1.X;
for (int i = 0; i < dtTeamPerson.Columns.Count; i++)
{
switch (dtTeamPerson.Columns[i].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
break;
default:
if (!this.chkYejiOrderBy.Checked)
{
if (dtTeamPerson.Columns[i].ColumnName.Trim() == "大队名称")
{
if (!string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()) || !string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{ break; }
}
if (dtTeamPerson.Columns[i].ColumnName.Trim() == "小组名称")
{
if (!string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{ break; }
}
}
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[i].ColumnName.Trim()].ToString().Trim());
SizeF sizef = g.MeasureString(dtTeamPerson.Columns[i].ColumnName.Trim(), ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
int FtHeigth = Convert.ToInt32(sizef.Height);
Rectangle rec1_1 = new Rectangle(intForTitleLeft + IntColumnWidth / 2 - FtWidth / 2, rec1.Y + TopAdd, IntColumnWidth, FtHeigth);
g.DrawString(dtTeamPerson.Columns[i].ColumnName.Trim(), ft11b, Brushes.White, rec1_1);
if (i < dtTeamPerson.Columns.Count - 1)
{
Point p11_1 = new Point(intForTitleLeft + IntColumnWidth, rec1.Y);
Point p11_2 = new Point(intForTitleLeft + IntColumnWidth, rec1.Y + rec1.Height);
g.DrawLine(new Pen(Brushes.Lavender, 1), p11_1, p11_2);
}
intForTitleLeft += IntColumnWidth;
break;
}
}
int intForRowTop = rec1.Y;
#endregion
if (!this.chkYejiOrderBy.Checked)
{
if (string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()) && string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{
#region 只选择活动名称
DataTable dtTeamMaxGroupBy = this.GetTeamMaxGroupBy(dtTeamMax, dtTeamPerson);
DataTable dtTeamMinGroupBy = this.GetTeamMinGroupBy(dtTeamMin, dtTeamPerson);
DataRow[] dtRowMaxGroupBy = dtTeamMaxGroupBy.Select("", "完成任务 DESC");
for (int i = 0; i < dtRowMaxGroupBy.Length; i++)
{
#region 绘制大队
intForRowTop += RowHeight;
Rectangle recMax = new Rectangle(rec1.X, intForRowTop, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, recMax);
Rectangle recMaxBackColor = new Rectangle(recMax.X + 1, recMax.Y + 1, recMax.Width - 1, recMax.Height - 1);
g.FillRectangle(Brushes.LightSalmon, recMaxBackColor);
int intMaxGroupRowLeft = recMax.X;
for (int j = 0; j < dtTeamPerson.Columns.Count; j++)
{
switch (dtTeamPerson.Columns[j].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
break;
default:
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[j].ColumnName.Trim()].ToString().Trim());
if (dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("保底完成情况") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("目标完成情况") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("冲刺完成情况") != -1)
{
Rectangle recA = new Rectangle(intMaxGroupRowLeft + TopAdd, recMax.Y + (RowHeight - 20) / 2, 150, 20);
g.DrawRectangle(new Pen(Brushes.LightSkyBlue, 1), recA);
decimal decValue = Convert.ToDecimal(dtRowMaxGroupBy[i][dtTeamPerson.Columns[j].ColumnName.Trim()]);
int recBWidth = Convert.ToInt32(recA.Width * decValue / 100);
if (recBWidth > (recA.Width - 1))
{ recBWidth = recA.Width - 1; }
Rectangle recB = new Rectangle(recA.X + 1, recA.Y + 1, recBWidth, recA.Height - 1);
g.FillRectangle(Brushes.LightSlateGray, recB);
string StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decValue) + "%";
SizeF sizef = g.MeasureString(StrValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
Rectangle recC = new Rectangle(recA.X + recA.Width + TopAdd, intForRowTop + TopAdd, FtWidth, RowHeight);
g.DrawString(StrValue, ft11b, b, recC);
}
else
{
string StrStringValue = dtRowMaxGroupBy[i][dtTeamPerson.Columns[j].ColumnName.Trim()].ToString().Trim();
int WidthLeft = intMaxGroupRowLeft;
if (dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("任务") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("业绩") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("均价") != -1)
{
StrStringValue = Convert.ToDecimal(StrStringValue).ToString("0.00");
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intMaxGroupRowLeft + IntColumnWidth - FtWidth - TopAdd;
}
else if (dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("单数") != -1)
{
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intMaxGroupRowLeft + IntColumnWidth / 2 - FtWidth / 2;
}
else
{
WidthLeft = intMaxGroupRowLeft + TopAdd;
}
Rectangle rec1_1 = new Rectangle(WidthLeft, intForRowTop + TopAdd, IntColumnWidth, RowHeight);
g.DrawString(StrStringValue, ft11b, b, rec1_1);
}
Point p11_1 = new Point(intMaxGroupRowLeft + IntColumnWidth, intForRowTop);
Point p11_2 = new Point(intMaxGroupRowLeft + IntColumnWidth, intForRowTop + recMax.Height);
g.DrawLine(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, p11_1, p11_2);
intMaxGroupRowLeft += IntColumnWidth;
break;
}
}
#endregion
DataRow[] dtMinGroupBy = dtTeamMinGroupBy.Select("大队编号 = '" + dtRowMaxGroupBy[i]["大队编号"].ToString().Trim() + "'", "完成任务 DESC");
for (int j = 0; j < dtMinGroupBy.Length; j++)
{
#region 绘制小组
intForRowTop += RowHeight;
Rectangle recMin = new Rectangle(rec1.X, intForRowTop, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, recMin);
int MaxTeamWidth = Convert.ToInt32(htColumnWidth["大队名称"]);
Rectangle recMinBackColor = new Rectangle(recMin.X + MaxTeamWidth + 1, recMin.Y + 1, recMin.Width - MaxTeamWidth - 1, recMin.Height - 1);
g.FillRectangle(Brushes.Wheat, recMinBackColor);
int intMinGroupRowLeft = recMin.X;
for (int k = 0; k < dtTeamPerson.Columns.Count; k++)
{
switch (dtTeamPerson.Columns[k].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
break;
default:
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[k].ColumnName.Trim()].ToString().Trim());
if (dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("保底完成情况") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("目标完成情况") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("冲刺完成情况") != -1)
{
Rectangle recA = new Rectangle(intMinGroupRowLeft + TopAdd, recMin.Y + (RowHeight - 20) / 2, 150, 20);
g.DrawRectangle(new Pen(Brushes.LightSkyBlue, 1), recA);
decimal decValue = Convert.ToDecimal(dtMinGroupBy[j][dtTeamPerson.Columns[k].ColumnName.Trim()]);
int recBWidth = Convert.ToInt32(recA.Width * decValue / 100);
if (recBWidth > (recA.Width - 1))
{ recBWidth = recA.Width - 1; }
Rectangle recB = new Rectangle(recA.X + 1, recA.Y + 1, recBWidth, recA.Height - 1);
g.FillRectangle(Brushes.LightSlateGray, recB);
string StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decValue) + "%";
SizeF sizef = g.MeasureString(StrValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
Rectangle recC = new Rectangle(recA.X + recA.Width + TopAdd, intForRowTop + TopAdd, FtWidth, RowHeight);
g.DrawString(StrValue, ft11b, b, recC);
}
else
{
string StrStringValue = dtMinGroupBy[j][dtTeamPerson.Columns[k].ColumnName.Trim()].ToString().Trim();
int WidthLeft = intMinGroupRowLeft;
if (dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("任务") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("业绩") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("均价") != -1)
{
StrStringValue = Convert.ToDecimal(StrStringValue).ToString("0.00");
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intMinGroupRowLeft + IntColumnWidth - FtWidth - TopAdd;
}
else if (dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("单数") != -1)
{
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intMinGroupRowLeft + IntColumnWidth / 2 - FtWidth / 2;
}
else
{
WidthLeft = intMinGroupRowLeft + TopAdd;
}
Rectangle rec1_1 = new Rectangle(WidthLeft, intForRowTop + TopAdd, IntColumnWidth, RowHeight);
g.DrawString(StrStringValue, ft11b, b, rec1_1);
}
Point p11_1 = new Point(intMinGroupRowLeft + IntColumnWidth, intForRowTop);
Point p11_2 = new Point(intMinGroupRowLeft + IntColumnWidth, intForRowTop + recMin.Height);
g.DrawLine(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, p11_1, p11_2);
intMinGroupRowLeft += IntColumnWidth;
break;
}
}
#endregion
DataRow[] dtRowTeamPerson = dtTeamPerson.Select("大队编号 = '" + dtRowMaxGroupBy[i]["大队编号"].ToString().Trim() + "' And 小组编号 = '" + dtMinGroupBy[j]["小组编号"].ToString().Trim() + "'", "完成任务 DESC");
for (int k = 0; k < dtRowTeamPerson.Length; k++)
{
#region 绘制组员
intForRowTop += RowHeight;
Rectangle recGroup = new Rectangle(rec1.X, intForRowTop, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, recGroup);
int intGroupRowLeft = recGroup.X;
for (int l = 0; l < dtTeamPerson.Columns.Count; l++)
{
switch (dtTeamPerson.Columns[l].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
break;
default:
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[l].ColumnName.Trim()].ToString().Trim());
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("保底完成情况") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("目标完成情况") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("冲刺完成情况") != -1)
{
Rectangle recA = new Rectangle(intGroupRowLeft + TopAdd, recGroup.Y + (RowHeight - 20) / 2, 150, 20);
g.DrawRectangle(new Pen(Brushes.LightSkyBlue, 1), recA);
decimal decValue = Convert.ToDecimal(dtRowTeamPerson[k][dtTeamPerson.Columns[l].ColumnName.Trim()]);
int recBWidth = Convert.ToInt32(recA.Width * decValue / 100);
if (recBWidth > (recA.Width - 1))
{ recBWidth = recA.Width - 1; }
Rectangle recB = new Rectangle(recA.X + 1, recA.Y + 1, recBWidth, recA.Height - 1);
g.FillRectangle(Brushes.LightSlateGray, recB);
string StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decValue) + "%";
SizeF sizef = g.MeasureString(StrValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
Rectangle recC = new Rectangle(recA.X + recA.Width + TopAdd, intForRowTop + TopAdd, FtWidth, RowHeight);
g.DrawString(StrValue, ft11b, b, recC);
}
else
{
string StrStringValue = dtRowTeamPerson[k][dtTeamPerson.Columns[l].ColumnName.Trim()].ToString().Trim();
int WidthLeft = intGroupRowLeft;
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("任务") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("业绩") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("均价") != -1)
{
StrStringValue = Convert.ToDecimal(StrStringValue).ToString("0.00");
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intGroupRowLeft + IntColumnWidth - FtWidth - TopAdd;
}
else if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("单数") != -1)
{
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intGroupRowLeft + IntColumnWidth / 2 - FtWidth / 2;
}
else
{
WidthLeft = intGroupRowLeft + TopAdd;
}
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("大队名称") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("小组名称") != -1)
{
StrStringValue = "";
}
Rectangle rec1_1 = new Rectangle(WidthLeft, intForRowTop + TopAdd, IntColumnWidth, RowHeight);
g.DrawString(StrStringValue, ft11b, b, rec1_1);
}
Point p11_1 = new Point(intGroupRowLeft + IntColumnWidth, intForRowTop);
Point p11_2 = new Point(intGroupRowLeft + IntColumnWidth, intForRowTop + recGroup.Height);
g.DrawLine(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, p11_1, p11_2);
intGroupRowLeft += IntColumnWidth;
break;
}
}
#endregion
}
}
}
#endregion
}
else if (!string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()) && string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{
#region 只选择活动名称和大队名称
DataTable dtTeamMinGroupBy = this.GetTeamMinGroupBy(dtTeamMin, dtTeamPerson);
DataRow[] dtMinGroupBy = dtTeamMinGroupBy.Select("大队编号 = '" + this.cmbtreevMaxTeamName.StrGetName.ToString().Trim() + "'", "完成任务 DESC");
for (int j = 0; j < dtMinGroupBy.Length; j++)
{
#region 绘制小组
intForRowTop += RowHeight;
Rectangle recMin = new Rectangle(rec1.X, intForRowTop, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, recMin);
Rectangle recMinBackColor = new Rectangle(recMin.X + 1, recMin.Y + 1, recMin.Width - 1, recMin.Height - 1);
g.FillRectangle(Brushes.Wheat, recMinBackColor);
int intMinGroupRowLeft = recMin.X;
for (int k = 0; k < dtTeamPerson.Columns.Count; k++)
{
switch (dtTeamPerson.Columns[k].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
case "大队名称":
break;
default:
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[k].ColumnName.Trim()].ToString().Trim());
if (dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("保底完成情况") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("目标完成情况") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("冲刺完成情况") != -1)
{
Rectangle recA = new Rectangle(intMinGroupRowLeft + TopAdd, recMin.Y + (RowHeight - 20) / 2, 150, 20);
g.DrawRectangle(new Pen(Brushes.LightSkyBlue, 1), recA);
decimal decValue = Convert.ToDecimal(dtMinGroupBy[j][dtTeamPerson.Columns[k].ColumnName.Trim()]);
int recBWidth = Convert.ToInt32(recA.Width * decValue / 100);
if (recBWidth > (recA.Width - 1))
{ recBWidth = recA.Width - 1; }
Rectangle recB = new Rectangle(recA.X + 1, recA.Y + 1, recBWidth, recA.Height - 1);
g.FillRectangle(Brushes.LightSlateGray, recB);
string StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decValue) + "%";
SizeF sizef = g.MeasureString(StrValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
Rectangle recC = new Rectangle(recA.X + recA.Width + TopAdd, intForRowTop + TopAdd, FtWidth, RowHeight);
g.DrawString(StrValue, ft11b, b, recC);
}
else
{
string StrStringValue = dtMinGroupBy[j][dtTeamPerson.Columns[k].ColumnName.Trim()].ToString().Trim();
int WidthLeft = intMinGroupRowLeft;
if (dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("任务") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("业绩") != -1 || dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("均价") != -1)
{
StrStringValue = Convert.ToDecimal(StrStringValue).ToString("0.00");
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intMinGroupRowLeft + IntColumnWidth - FtWidth - TopAdd;
}
else if (dtTeamPerson.Columns[k].ColumnName.Trim().IndexOf("单数") != -1)
{
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intMinGroupRowLeft + IntColumnWidth / 2 - FtWidth / 2;
}
else
{ WidthLeft = intMinGroupRowLeft + TopAdd; }
Rectangle rec1_1 = new Rectangle(WidthLeft, intForRowTop + TopAdd, IntColumnWidth, RowHeight);
g.DrawString(StrStringValue, ft11b, b, rec1_1);
}
Point p11_1 = new Point(intMinGroupRowLeft + IntColumnWidth, intForRowTop);
Point p11_2 = new Point(intMinGroupRowLeft + IntColumnWidth, intForRowTop + recMin.Height);
g.DrawLine(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, p11_1, p11_2);
intMinGroupRowLeft += IntColumnWidth;
break;
}
}
#endregion
DataRow[] dtRowTeamPerson = dtTeamPerson.Select("大队编号 = '" + this.cmbtreevMaxTeamName.StrGetName.ToString().Trim() + "' And 小组编号 = '" + dtMinGroupBy[j]["小组编号"].ToString().Trim() + "'", "完成任务 DESC");
for (int k = 0; k < dtRowTeamPerson.Length; k++)
{
#region 绘制组员
intForRowTop += RowHeight;
Rectangle recGroup = new Rectangle(rec1.X, intForRowTop, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, recGroup);
int intGroupRowLeft = recGroup.X;
for (int l = 0; l < dtTeamPerson.Columns.Count; l++)
{
switch (dtTeamPerson.Columns[l].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
case "大队名称":
break;
default:
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[l].ColumnName.Trim()].ToString().Trim());
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("保底完成情况") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("目标完成情况") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("冲刺完成情况") != -1)
{
Rectangle recA = new Rectangle(intGroupRowLeft + TopAdd, recGroup.Y + (RowHeight - 20) / 2, 150, 20);
g.DrawRectangle(new Pen(Brushes.LightSkyBlue, 1), recA);
decimal decValue = Convert.ToDecimal(dtRowTeamPerson[k][dtTeamPerson.Columns[l].ColumnName.Trim()]);
int recBWidth = Convert.ToInt32(recA.Width * decValue / 100);
if (recBWidth > (recA.Width - 1))
{ recBWidth = recA.Width - 1; }
Rectangle recB = new Rectangle(recA.X + 1, recA.Y + 1, recBWidth, recA.Height - 1);
g.FillRectangle(Brushes.LightSlateGray, recB);
string StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decValue) + "%";
SizeF sizef = g.MeasureString(StrValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
Rectangle recC = new Rectangle(recA.X + recA.Width + TopAdd, intForRowTop + TopAdd, FtWidth, RowHeight);
g.DrawString(StrValue, ft11b, b, recC);
}
else
{
string StrStringValue = dtRowTeamPerson[k][dtTeamPerson.Columns[l].ColumnName.Trim()].ToString().Trim();
int WidthLeft = intGroupRowLeft;
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("任务") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("业绩") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("均价") != -1)
{
StrStringValue = Convert.ToDecimal(StrStringValue).ToString("0.00");
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intGroupRowLeft + IntColumnWidth - FtWidth - TopAdd;
}
else if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("单数") != -1)
{
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intGroupRowLeft + IntColumnWidth / 2 - FtWidth / 2;
}
else
{ WidthLeft = intGroupRowLeft + TopAdd; }
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("大队名称") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("小组名称") != -1)
{ StrStringValue = ""; }
Rectangle rec1_1 = new Rectangle(WidthLeft, intForRowTop + TopAdd, IntColumnWidth, RowHeight);
g.DrawString(StrStringValue, ft11b, b, rec1_1);
}
Point p11_1 = new Point(intGroupRowLeft + IntColumnWidth, intForRowTop);
Point p11_2 = new Point(intGroupRowLeft + IntColumnWidth, intForRowTop + recGroup.Height);
g.DrawLine(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, p11_1, p11_2);
intGroupRowLeft += IntColumnWidth;
break;
}
}
#endregion
}
}
#endregion
}
else if (!string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()) && !string.IsNullOrEmpty(this.cmbtreevMinTeamName.Text.Trim()))
{
#region 选择活动名称和大队名称、小组名称
DataRow[] dtRowTeamPerson = dtTeamPerson.Select("大队编号 = '" + this.cmbtreevMaxTeamName.StrGetName.ToString().Trim() + "' And 小组编号 = '" + this.cmbtreevMinTeamName.StrGetName.ToString().Trim() + "'", "完成任务 DESC");
for (int k = 0; k < dtRowTeamPerson.Length; k++)
{
#region 绘制组员
intForRowTop += RowHeight;
Rectangle recGroup = new Rectangle(rec1.X, intForRowTop, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, recGroup);
Rectangle rec2_1 = new Rectangle(recGroup.X + 1, recGroup.Y + 1, recGroup.Width - 1, recGroup.Height - 1);
if ((k % 2) > 0)
{ g.FillRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.brSingle, rec2_1); }
else
{ g.FillRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.brDouble, rec2_1); }
int intGroupRowLeft = recGroup.X;
for (int l = 0; l < dtTeamPerson.Columns.Count; l++)
{
switch (dtTeamPerson.Columns[l].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
case "大队名称":
case "小组名称":
break;
default:
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[l].ColumnName.Trim()].ToString().Trim());
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("保底完成情况") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("目标完成情况") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("冲刺完成情况") != -1)
{
Rectangle recA = new Rectangle(intGroupRowLeft + TopAdd, recGroup.Y + (RowHeight - 20) / 2, 150, 20);
g.DrawRectangle(new Pen(Brushes.LightSkyBlue, 1), recA);
decimal decValue = Convert.ToDecimal(dtRowTeamPerson[k][dtTeamPerson.Columns[l].ColumnName.Trim()]);
int recBWidth = Convert.ToInt32(recA.Width * decValue / 100);
if (recBWidth > (recA.Width - 1))
{ recBWidth = recA.Width - 1; }
Rectangle recB = new Rectangle(recA.X + 1, recA.Y + 1, recBWidth, recA.Height - 1);
g.FillRectangle(Brushes.LightSlateGray, recB);
string StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decValue) + "%";
SizeF sizef = g.MeasureString(StrValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
Rectangle recC = new Rectangle(recA.X + recA.Width + TopAdd, intForRowTop + TopAdd, FtWidth, RowHeight);
g.DrawString(StrValue, ft11b, b, recC);
}
else
{
string StrStringValue = dtRowTeamPerson[k][dtTeamPerson.Columns[l].ColumnName.Trim()].ToString().Trim();
int WidthLeft = intGroupRowLeft;
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("任务") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("业绩") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("均价") != -1)
{
StrStringValue = Convert.ToDecimal(StrStringValue).ToString("0.00");
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intGroupRowLeft + IntColumnWidth - FtWidth - TopAdd;
}
else if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("单数") != -1)
{
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intGroupRowLeft + IntColumnWidth / 2 - FtWidth / 2;
}
else
{ WidthLeft = intGroupRowLeft + TopAdd; }
if (dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("大队名称") != -1 || dtTeamPerson.Columns[l].ColumnName.Trim().IndexOf("小组名称") != -1)
{ StrStringValue = ""; }
Rectangle rec1_1 = new Rectangle(WidthLeft, intForRowTop + TopAdd, IntColumnWidth, RowHeight);
g.DrawString(StrStringValue, ft11b, b, rec1_1);
}
Point p11_1 = new Point(intGroupRowLeft + IntColumnWidth, intForRowTop);
Point p11_2 = new Point(intGroupRowLeft + IntColumnWidth, intForRowTop + recGroup.Height);
g.DrawLine(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, p11_1, p11_2);
intGroupRowLeft += IntColumnWidth;
break;
}
}
#endregion
}
#endregion
}
}
else
{
#region 按个人业绩排序
DataRow[] dtRows = dtTeamPerson.Select("", "完成任务 DESC,小组名称 ASC,员工姓名 ASC");
for (int i = 0; i < dtRows.Length; i++)
{
intForRowTop += RowHeight;
Rectangle rec2 = new Rectangle(rec1.X, intForRowTop, TableWidth, RowHeight);
g.DrawRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, rec2);
Rectangle rec2_1 = new Rectangle(rec1.X + 1, rec2.Y + 1, rec2.Width - 1, rec2.Height - 1);
if ((i % 2) > 0)
{ g.FillRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.brSingle, rec2_1); }
else
{ g.FillRectangle(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.brDouble, rec2_1); }
int intForRowLeft = rec2.X;
for (int j = 0; j < dtTeamPerson.Columns.Count; j++)
{
switch (dtTeamPerson.Columns[j].ColumnName.Trim())
{
case "大队编号":
case "小组编号":
break;
default:
int IntColumnWidth = Convert.ToInt32(htColumnWidth[dtTeamPerson.Columns[j].ColumnName.Trim()].ToString().Trim());
if (dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("保底完成情况") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("目标完成情况") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("冲刺完成情况") != -1)
{
Rectangle recA = new Rectangle(intForRowLeft + TopAdd, rec2.Y + (RowHeight - 20) / 2, 150, 20);
g.DrawRectangle(new Pen(Brushes.LightSkyBlue, 1), recA);
decimal decValue = Convert.ToDecimal(dtRows[i][dtTeamPerson.Columns[j].ColumnName.Trim()]);
int recBWidth = Convert.ToInt32(recA.Width * decValue / 100);
if (recBWidth > (recA.Width - 1))
{ recBWidth = recA.Width - 1; }
Rectangle recB = new Rectangle(recA.X + 1, recA.Y + 1, recBWidth, recA.Height - 1);
g.FillRectangle(Brushes.LightSlateGray, recB);
string StrValue = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decValue) + "%";
SizeF sizef = g.MeasureString(StrValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
Rectangle recC = new Rectangle(recA.X + recA.Width + TopAdd, intForRowTop + TopAdd, FtWidth, RowHeight);
g.DrawString(StrValue, ft11b, b, recC);
}
else
{
string StrStringValue = dtRows[i][dtTeamPerson.Columns[j].ColumnName.Trim()].ToString().Trim();
int WidthLeft = intForRowLeft;
if (dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("任务") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("业绩") != -1 || dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("均价") != -1)
{
StrStringValue = Convert.ToDecimal(StrStringValue).ToString("0.00");
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intForRowLeft + IntColumnWidth - FtWidth - TopAdd;
}
else if (dtTeamPerson.Columns[j].ColumnName.Trim().IndexOf("单数") != -1)
{
SizeF sizef = g.MeasureString(StrStringValue, ft11b);
int FtWidth = Convert.ToInt32(sizef.Width) + 1;
WidthLeft = intForRowLeft + IntColumnWidth / 2 - FtWidth / 2;
}
else
{ WidthLeft = intForRowLeft + TopAdd; }
Rectangle rec1_1 = new Rectangle(WidthLeft, intForRowTop + TopAdd, IntColumnWidth, RowHeight);
g.DrawString(StrStringValue, ft11b, b, rec1_1);
}
Point p11_1 = new Point(intForRowLeft + IntColumnWidth, intForRowTop);
Point p11_2 = new Point(intForRowLeft + IntColumnWidth, intForRowTop + rec2.Height);
g.DrawLine(LYFZ.Software.MainBusiness.DoorCityProcess.PublicGraphics.PenborderColor, p11_1, p11_2);
intForRowLeft += IntColumnWidth;
break;
}
}
}
#endregion
}
this.pictImage.Dock = DockStyle.None;
this.pictImage.Image = newBmp;
this.pictImage.Height = newBmp.Height;
this.pictImage.Width = newBmp.Width;
}
}
}
///
/// 获取列宽
///
Hashtable GetColumnWidth()
{
Hashtable htColumnWidth = new Hashtable();
htColumnWidth["大队名称"] = 130;
htColumnWidth["小组名称"] = 130;
htColumnWidth["员工姓名"] = 100;
htColumnWidth["完成任务"] = 100;
htColumnWidth["保底任务"] = 100;
htColumnWidth["保底完成情况"] = 230;
htColumnWidth["目标任务"] = 100;
htColumnWidth["目标完成情况"] = 230;
htColumnWidth["冲刺任务"] = 100;
htColumnWidth["冲刺完成情况"] = 230;
htColumnWidth["婚纱单数"] = 100;
htColumnWidth["婚纱业绩"] = 100;
htColumnWidth["婚纱均价"] = 100;
htColumnWidth["儿童单数"] = 100;
htColumnWidth["儿童业绩"] = 100;
htColumnWidth["儿童均价"] = 100;
htColumnWidth["写真单数"] = 100;
htColumnWidth["写真业绩"] = 100;
htColumnWidth["写真均价"] = 100;
htColumnWidth["服务单数"] = 100;
htColumnWidth["服务业绩"] = 100;
htColumnWidth["服务均价"] = 100;
htColumnWidth["婚庆单数"] = 100;
htColumnWidth["婚庆业绩"] = 100;
htColumnWidth["婚庆均价"] = 100;
return htColumnWidth;
}
///
/// 组织收款接单人数据
///
///
DataTable OpenOrderPersonDataTable(DateTime StrTimeStart, DateTime StrTimeEnd)
{
DataTable NewTable = new DataTable();
NewTable.Columns.Add("OrdNumber", typeof(string));
NewTable.Columns.Add("OpenSingle", typeof(string));
NewTable.Columns.Add("OrdType", typeof(string));
NewTable.Columns.Add("PaymentAmount", typeof(decimal));
NewTable.Columns.Add("SeriesPrice", typeof(decimal));
NewTable.Columns.Add("MinVice", typeof(string));
string StrTableName = "tb_ErpPayment Left Join tb_ErpOrder on Ord_Number = Pay_OrdNumber";
string StrWhere = "Pay_Type = '0' And Pay_Category in ('预约收款', '预约补款', '全款') And (Pay_CreateDatetime between '" + StrTimeStart.ToString("yyyy-MM-dd HH:mm:ss") + "' And '" + StrTimeEnd.ToString("yyyy-MM-dd HH:mm:ss") + "')";
string StrColumnName = "Pay_OrdNumber,Sum(Pay_AmountOf) AS Pay_AmountOf,Pay_OpenSingle,Ord_Type,Max(Ord_SeriesPrice) AS Ord_SeriesPrice";
DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: StrWhere, ShowColumnName: StrColumnName, GroupBy: "Pay_OrdNumber,Pay_OpenSingle,Ord_Type").Tables[0];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string[] StrArray = dt.Rows[i]["Pay_OpenSingle"].ToString().Trim().Split(',');
for (int j = 0; j < StrArray.Length; j++)
{
if (!string.IsNullOrEmpty(StrArray[j].Trim()))
{
DataRow newRow = NewTable.NewRow();
newRow["OrdNumber"] = dt.Rows[i]["Pay_OrdNumber"].ToString().Trim();
newRow["OpenSingle"] = StrArray[j].Trim();
newRow["OrdType"] = dt.Rows[i]["Ord_Type"].ToString().Trim();
decimal decAmount = Convert.ToDecimal(dt.Rows[i]["Pay_AmountOf"]) / (MinStoreProportion + ViceStoreProportion * (dt.Rows[i]["Pay_OpenSingle"].ToString().Trim().Length - dt.Rows[i]["Pay_OpenSingle"].ToString().Trim().Replace(",", "").Trim().Length));
if (j == 0)
{
newRow["PaymentAmount"] = decAmount * MinStoreProportion;
newRow["SeriesPrice"] = Convert.ToDecimal(dt.Rows[i]["Ord_SeriesPrice"]);
newRow["MinVice"] = "Min";
}
else
{
newRow["PaymentAmount"] = decAmount * ViceStoreProportion;
newRow["SeriesPrice"] = 0;
newRow["MinVice"] = "Vice";
}
NewTable.Rows.Add(newRow);
}
}
}
}
return NewTable;
}
///
/// 合并计算实收金额
///
///
///
DataTable OpenOrderPersonGroupDataTable(DataTable dt)
{
Hashtable htData = new Hashtable();
for (int i = 0; i < dt.Rows.Count; i++)
{
string StrKeys = dt.Rows[i]["OpenSingle"].ToString().Trim();
DataRow[] dtRow = dt.Select("OpenSingle = '" + StrKeys.Trim() + "' And OrdType = '0' And MinVice = 'Min'");
DataRow[] dtRow1 = dt.Select("OpenSingle = '" + StrKeys.Trim() + "' And OrdType = '1' And MinVice = 'Min'");
DataRow[] dtRow2 = dt.Select("OpenSingle = '" + StrKeys.Trim() + "' And OrdType = '2' And MinVice = 'Min'");
DataRow[] dtRow3 = dt.Select("OpenSingle = '" + StrKeys.Trim() + "' And OrdType = '3' And MinVice = 'Min'");
DataRow[] dtRow4 = dt.Select("OpenSingle = '" + StrKeys.Trim() + "' And OrdType = '4' And MinVice = 'Min'");
decimal SeriesPrice = 0;
decimal SeriesPrice1 = 0;
decimal SeriesPrice2 = 0;
decimal SeriesPrice3 = 0;
decimal SeriesPrice4 = 0;
for (int j = 0; j < dtRow.Length; j++)
{ SeriesPrice += Convert.ToDecimal(dtRow[j]["SeriesPrice"]); }
for (int j = 0; j < dtRow1.Length; j++)
{ SeriesPrice1 += Convert.ToDecimal(dtRow1[j]["SeriesPrice"]); }
for (int j = 0; j < dtRow2.Length; j++)
{ SeriesPrice2 += Convert.ToDecimal(dtRow2[j]["SeriesPrice"]); }
for (int j = 0; j < dtRow3.Length; j++)
{ SeriesPrice3 += Convert.ToDecimal(dtRow3[j]["SeriesPrice"]); }
for (int j = 0; j < dtRow4.Length; j++)
{ SeriesPrice4 += Convert.ToDecimal(dtRow4[j]["SeriesPrice"]); }
string StrOrdering = "0:" + dtRow.Length + ":" + SeriesPrice;
StrOrdering += "/1:" + dtRow1.Length + ":" + SeriesPrice1;
StrOrdering += "/2:" + dtRow2.Length + ":" + SeriesPrice2;
StrOrdering += "/3:" + dtRow3.Length + ":" + SeriesPrice3;
StrOrdering += "/4:" + dtRow4.Length + ":" + SeriesPrice4;
if (htData.ContainsKey(StrKeys))
{
string[] StrValue = htData[StrKeys].ToString().Trim().Split('|');
decimal decPaymentAmount = Convert.ToDecimal(dt.Rows[i]["PaymentAmount"]) + Convert.ToDecimal(StrValue[0].Trim());
//decimal decSeriesPrice = Convert.ToDecimal(dt.Rows[i]["SeriesPrice"]) + Convert.ToDecimal(StrValue[1].Trim());
htData[StrKeys] = decPaymentAmount.ToString().Trim() + "|" + StrOrdering;
//htData[StrKeys] = decPaymentAmount.ToString().Trim() + "|" + decSeriesPrice.ToString().Trim() + "|" + dtRow.Length.ToString().Trim();
}
else
{ htData[StrKeys] = dt.Rows[i]["PaymentAmount"].ToString().Trim() + "|" + StrOrdering; }
}
DataTable NewTable = new DataTable();
NewTable.Columns.Add("OpenSingle", typeof(string));
NewTable.Columns.Add("PaymentAmount", typeof(decimal));
NewTable.Columns.Add("SeriesPrice", typeof(decimal));
NewTable.Columns.Add("Quantity", typeof(int));
NewTable.Columns.Add("AveragePrice", typeof(string));
NewTable.Columns.Add("SeriesPrice1", typeof(decimal));
NewTable.Columns.Add("Quantity1", typeof(int));
NewTable.Columns.Add("AveragePrice1", typeof(string));
NewTable.Columns.Add("SeriesPrice2", typeof(decimal));
NewTable.Columns.Add("Quantity2", typeof(int));
NewTable.Columns.Add("AveragePrice2", typeof(string));
NewTable.Columns.Add("SeriesPrice3", typeof(decimal));
NewTable.Columns.Add("Quantity3", typeof(int));
NewTable.Columns.Add("AveragePrice3", typeof(string));
NewTable.Columns.Add("SeriesPrice4", typeof(decimal));
NewTable.Columns.Add("Quantity4", typeof(int));
NewTable.Columns.Add("AveragePrice4", typeof(string));
switch (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
{
case LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.婚纱版:
NewTable.Columns.Remove("SeriesPrice1");
NewTable.Columns.Remove("Quantity1");
NewTable.Columns.Remove("AveragePrice1");
break;
case LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.儿童版:
NewTable.Columns.Remove("SeriesPrice");
NewTable.Columns.Remove("Quantity");
NewTable.Columns.Remove("AveragePrice");
break;
default:
break;
}
if (!LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsEnablePhotoEdition)
{
NewTable.Columns.Remove("SeriesPrice2");
NewTable.Columns.Remove("Quantity2");
NewTable.Columns.Remove("AveragePrice2");
}
foreach (DictionaryEntry item in htData)
{
string StrKey = item.Key.ToString().Trim();
string[] StrArrayValue = item.Value.ToString().Trim().Split('|');
DataRow newRow = NewTable.NewRow();
newRow["OpenSingle"] = StrKey.Trim();
newRow["PaymentAmount"] = Convert.ToDecimal(StrArrayValue[0].Trim());
string[] StrArrayType = StrArrayValue[1].Trim().Split('/');
for (int i = 0; i < StrArrayType.Length; i++)
{
string[] StrArray = StrArrayType[i].Trim().Split(':');
switch (StrArray[0].Trim())
{
case "0":
if (NewTable.Columns.Contains("SeriesPrice"))
{
newRow["Quantity"] = StrArray[1].Trim();
newRow["SeriesPrice"] = StrArray[2].Trim();
newRow["AveragePrice"] = 0;
if (Convert.ToDecimal(StrArray[1]) > 0)
{ newRow["AveragePrice"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((Convert.ToDecimal(StrArray[2]) / Convert.ToDecimal(StrArray[1])).ToString("0.00")); }
}
break;
case "1":
if (NewTable.Columns.Contains("SeriesPrice1"))
{
newRow["Quantity1"] = StrArray[1].Trim();
newRow["SeriesPrice1"] = StrArray[2].Trim();
newRow["AveragePrice1"] = 0;
if (Convert.ToDecimal(StrArray[1]) > 0)
{ newRow["AveragePrice1"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((Convert.ToDecimal(StrArray[2]) / Convert.ToDecimal(StrArray[1])).ToString("0.00")); }
}
break;
case "2":
if (NewTable.Columns.Contains("SeriesPrice2"))
{
newRow["Quantity2"] = StrArray[1].Trim();
newRow["SeriesPrice2"] = StrArray[2].Trim();
newRow["AveragePrice2"] = 0;
if (Convert.ToDecimal(StrArray[1]) > 0)
{ newRow["AveragePrice2"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((Convert.ToDecimal(StrArray[2]) / Convert.ToDecimal(StrArray[1])).ToString("0.00")); }
}
break;
case "3":
if (NewTable.Columns.Contains("SeriesPrice3"))
{
newRow["Quantity3"] = StrArray[1].Trim();
newRow["SeriesPrice3"] = StrArray[2].Trim();
newRow["AveragePrice3"] = 0;
if (Convert.ToDecimal(StrArray[1]) > 0)
{ newRow["AveragePrice3"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((Convert.ToDecimal(StrArray[2]) / Convert.ToDecimal(StrArray[1])).ToString("0.00")); }
}
break;
case "4":
if (NewTable.Columns.Contains("SeriesPrice4"))
{
newRow["Quantity4"] = StrArray[1].Trim();
newRow["SeriesPrice4"] = StrArray[2].Trim();
newRow["AveragePrice4"] = 0;
if (Convert.ToDecimal(StrArray[1]) > 0)
{ newRow["AveragePrice4"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((Convert.ToDecimal(StrArray[2]) / Convert.ToDecimal(StrArray[1])).ToString("0.00")); }
}
break;
}
}
NewTable.Rows.Add(newRow);
}
return NewTable;
}
///
/// 获取参与活动的所有小组人员的数据
///
///
DataTable TeamPersonRankedDataTable(DataTable dtTeamPerson, DataTable dtOpenSingle)
{
DataTable NewTable = new DataTable();
NewTable.Columns.Add("大队编号", typeof(string));
NewTable.Columns.Add("小组编号", typeof(string));
NewTable.Columns.Add("大队名称", typeof(string));
NewTable.Columns.Add("小组名称", typeof(string));
NewTable.Columns.Add("员工姓名", typeof(string));
NewTable.Columns.Add("完成任务", typeof(decimal));
NewTable.Columns.Add("保底任务", typeof(string));
NewTable.Columns.Add("保底完成情况", typeof(string));
NewTable.Columns.Add("目标任务", typeof(string));
NewTable.Columns.Add("目标完成情况", typeof(string));
NewTable.Columns.Add("冲刺任务", typeof(string));
NewTable.Columns.Add("冲刺完成情况", typeof(string));
if (dtOpenSingle.Columns.Contains("SeriesPrice"))
{
NewTable.Columns.Add("婚纱单数", typeof(string));
NewTable.Columns.Add("婚纱业绩", typeof(string));
NewTable.Columns.Add("婚纱均价", typeof(string));
}
if (dtOpenSingle.Columns.Contains("SeriesPrice1"))
{
NewTable.Columns.Add("儿童单数", typeof(string));
NewTable.Columns.Add("儿童业绩", typeof(string));
NewTable.Columns.Add("儿童均价", typeof(string));
}
if (dtOpenSingle.Columns.Contains("SeriesPrice2"))
{
NewTable.Columns.Add("写真单数", typeof(string));
NewTable.Columns.Add("写真业绩", typeof(string));
NewTable.Columns.Add("写真均价", typeof(string));
}
if (dtOpenSingle.Columns.Contains("SeriesPrice3"))
{
NewTable.Columns.Add("服务单数", typeof(string));
NewTable.Columns.Add("服务业绩", typeof(string));
NewTable.Columns.Add("服务均价", typeof(string));
}
if (dtOpenSingle.Columns.Contains("SeriesPrice4"))
{
NewTable.Columns.Add("婚庆单数", typeof(string));
NewTable.Columns.Add("婚庆业绩", typeof(string));
NewTable.Columns.Add("婚庆均价", typeof(string));
}
for (int i = 0; i < dtTeamPerson.Rows.Count; i++)
{
DataRow[] dtRow = dtOpenSingle.Select("OpenSingle = '" + dtTeamPerson.Rows[i]["Tps_UserNumber"].ToString().Trim() + "'");
decimal decCompletedTask = 0;
if (dtRow.Length > 0)
{ decCompletedTask = Convert.ToDecimal(dtRow[0]["PaymentAmount"]); }
DataRow newRow = NewTable.NewRow();
newRow["大队编号"] = dtTeamPerson.Rows[i]["Tps_TmxtNumber"].ToString().Trim();
newRow["小组编号"] = dtTeamPerson.Rows[i]["Tps_TmitNumber"].ToString().Trim();
newRow["大队名称"] = dtTeamPerson.Rows[i]["Tmxn_Name"].ToString().Trim();
newRow["小组名称"] = dtTeamPerson.Rows[i]["Tmin_Name"].ToString().Trim();
newRow["员工姓名"] = dtTeamPerson.Rows[i]["User_Name"].ToString().Trim();
newRow["完成任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decCompletedTask);
newRow["保底任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamPerson.Rows[i]["Tps_BaodiTask"]);
newRow["保底完成情况"] = 0;
if (Convert.ToDecimal(dtTeamPerson.Rows[i]["Tps_BaodiTask"]) > 0)
{ newRow["保底完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamPerson.Rows[i]["Tps_BaodiTask"]) * 100).ToString("0.00")); }
newRow["目标任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamPerson.Rows[i]["Tps_TargetTask"]);
newRow["目标完成情况"] = 0;
if (Convert.ToDecimal(dtTeamPerson.Rows[i]["Tps_TargetTask"]) > 0)
{ newRow["目标完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamPerson.Rows[i]["Tps_TargetTask"]) * 100).ToString("0.00")); }
newRow["冲刺任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamPerson.Rows[i]["Tps_SprintTask"]);
newRow["冲刺完成情况"] = 0;
if (Convert.ToDecimal(dtTeamPerson.Rows[i]["Tps_SprintTask"]) > 0)
{ newRow["冲刺完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamPerson.Rows[i]["Tps_SprintTask"]) * 100).ToString("0.00")); }
if (NewTable.Columns.Contains("婚纱单数"))
{
newRow["婚纱单数"] = "0";
newRow["婚纱业绩"] = "0";
newRow["婚纱均价"] = "0";
if (dtOpenSingle.Columns.Contains("SeriesPrice") && dtRow.Length > 0)
{
newRow["婚纱单数"] = dtRow[0]["Quantity"].ToString().Trim();
newRow["婚纱业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtRow[0]["SeriesPrice"]);
newRow["婚纱均价"] = dtRow[0]["AveragePrice"].ToString().Trim();
}
}
if (NewTable.Columns.Contains("儿童单数"))
{
newRow["儿童单数"] = "0";
newRow["儿童业绩"] = "0";
newRow["儿童均价"] = "0";
if (dtOpenSingle.Columns.Contains("SeriesPrice1") && dtRow.Length > 0)
{
newRow["儿童单数"] = dtRow[0]["Quantity1"].ToString().Trim();
newRow["儿童业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtRow[0]["SeriesPrice1"]);
newRow["儿童均价"] = dtRow[0]["AveragePrice1"].ToString().Trim();
}
}
if (NewTable.Columns.Contains("写真单数"))
{
newRow["写真单数"] = "0";
newRow["写真业绩"] = "0";
newRow["写真均价"] = "0";
if (dtOpenSingle.Columns.Contains("SeriesPrice2") && dtRow.Length > 0)
{
newRow["写真单数"] = dtRow[0]["Quantity2"].ToString().Trim();
newRow["写真业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtRow[0]["SeriesPrice2"]);
newRow["写真均价"] = dtRow[0]["AveragePrice2"].ToString().Trim();
}
}
if (NewTable.Columns.Contains("服务单数"))
{
newRow["服务单数"] = "0";
newRow["服务业绩"] = "0";
newRow["服务均价"] = "0";
if (dtOpenSingle.Columns.Contains("SeriesPrice3") && dtRow.Length > 0)
{
newRow["服务单数"] = dtRow[0]["Quantity3"].ToString().Trim();
newRow["服务业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtRow[0]["SeriesPrice3"]);
newRow["服务均价"] = dtRow[0]["AveragePrice3"].ToString().Trim();
}
}
if (NewTable.Columns.Contains("婚庆单数"))
{
newRow["婚庆单数"] = "0";
newRow["婚庆业绩"] = "0";
newRow["婚庆均价"] = "0";
if (dtOpenSingle.Columns.Contains("SeriesPrice4") && dtRow.Length > 0)
{
newRow["婚庆单数"] = dtRow[0]["Quantity4"].ToString().Trim();
newRow["婚庆业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtRow[0]["SeriesPrice4"]);
newRow["婚庆均价"] = dtRow[0]["AveragePrice4"].ToString().Trim();
}
}
NewTable.Rows.Add(newRow);
}
return NewTable;
}
///
/// 获取大队的完成任务数据
///
///
///
///
DataTable GetTeamMaxGroupBy(DataTable dtTeamMax, DataTable dtTeamPerson)
{
DataTable NewTable = new DataTable();
NewTable.Columns.Add("活动编号", typeof(string));
NewTable.Columns.Add("大队编号", typeof(string));
NewTable.Columns.Add("大队名称", typeof(string));
NewTable.Columns.Add("小组名称", typeof(string));
NewTable.Columns.Add("员工姓名", typeof(string));
NewTable.Columns.Add("完成任务", typeof(decimal));
NewTable.Columns.Add("保底任务", typeof(string));
NewTable.Columns.Add("保底完成情况", typeof(string));
NewTable.Columns.Add("目标任务", typeof(string));
NewTable.Columns.Add("目标完成情况", typeof(string));
NewTable.Columns.Add("冲刺任务", typeof(string));
NewTable.Columns.Add("冲刺完成情况", typeof(string));
if (dtTeamPerson.Columns.Contains("婚纱单数"))
{
NewTable.Columns.Add("婚纱单数", typeof(string));
NewTable.Columns.Add("婚纱业绩", typeof(string));
NewTable.Columns.Add("婚纱均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("儿童单数"))
{
NewTable.Columns.Add("儿童单数", typeof(string));
NewTable.Columns.Add("儿童业绩", typeof(string));
NewTable.Columns.Add("儿童均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("写真单数"))
{
NewTable.Columns.Add("写真单数", typeof(string));
NewTable.Columns.Add("写真业绩", typeof(string));
NewTable.Columns.Add("写真均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("服务单数"))
{
NewTable.Columns.Add("服务单数", typeof(string));
NewTable.Columns.Add("服务业绩", typeof(string));
NewTable.Columns.Add("服务均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("婚庆单数"))
{
NewTable.Columns.Add("婚庆单数", typeof(string));
NewTable.Columns.Add("婚庆业绩", typeof(string));
NewTable.Columns.Add("婚庆均价", typeof(string));
}
for (int i = 0; i < dtTeamMax.Rows.Count; i++)
{
decimal decCompletedTask = 0;
int decCompleteWeddingQuantity = 0;
decimal decCompleteWeddingAmount = 0;
int CompleteChildrenQuantity = 0;
decimal CompleteChildrenAmount = 0;
int CompletePortraitQuantity = 0;
decimal CompletePortraitAmount = 0;
int CompleteServiceQuantity = 0;
decimal CompleteServiceAmount = 0;
int CompleteWeddingCelebrationQuantity = 0;
decimal CompleteWeddingCelebrationAmount = 0;
DataRow[] dtRowTeamPerson = dtTeamPerson.Select("大队编号 = '" + dtTeamMax.Rows[i]["Tmxt_Number"].ToString().Trim() + "'");
for (int j = 0; j < dtRowTeamPerson.Length; j++)
{
decCompletedTask += Convert.ToDecimal(dtRowTeamPerson[j]["完成任务"]);
if (NewTable.Columns.Contains("婚纱单数"))
{
decCompleteWeddingQuantity += Convert.ToInt32(dtRowTeamPerson[j]["婚纱单数"]);
decCompleteWeddingAmount += Convert.ToDecimal(dtRowTeamPerson[j]["婚纱业绩"]);
}
if (NewTable.Columns.Contains("儿童单数"))
{
CompleteChildrenQuantity += Convert.ToInt32(dtRowTeamPerson[j]["儿童单数"]);
CompleteChildrenAmount += Convert.ToDecimal(dtRowTeamPerson[j]["儿童业绩"]);
}
if (NewTable.Columns.Contains("写真单数"))
{
CompletePortraitQuantity += Convert.ToInt32(dtRowTeamPerson[j]["写真单数"]);
CompletePortraitAmount += Convert.ToDecimal(dtRowTeamPerson[j]["写真业绩"]);
}
if (NewTable.Columns.Contains("服务单数"))
{
CompleteServiceQuantity += Convert.ToInt32(dtRowTeamPerson[j]["服务单数"]);
CompleteServiceAmount += Convert.ToDecimal(dtRowTeamPerson[j]["服务业绩"]);
}
if (NewTable.Columns.Contains("婚庆单数"))
{
CompleteWeddingCelebrationQuantity += Convert.ToInt32(dtRowTeamPerson[j]["婚庆单数"]);
CompleteWeddingCelebrationAmount += Convert.ToDecimal(dtRowTeamPerson[j]["婚庆业绩"]);
}
}
DataRow newRow = NewTable.NewRow();
newRow["活动编号"] = dtTeamMax.Rows[i]["Tmxt_TasNumber"].ToString().Trim();
newRow["大队编号"] = dtTeamMax.Rows[i]["Tmxt_Number"].ToString().Trim();
newRow["大队名称"] = dtTeamMax.Rows[i]["Tmxn_Name"].ToString().Trim();
newRow["小组名称"] = "";
newRow["员工姓名"] = "";
newRow["完成任务"] = decCompletedTask;
newRow["保底任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamMax.Rows[i]["Tmxt_BaodiTask"].ToString().Trim());
newRow["保底完成情况"] = 0;
if (Convert.ToDecimal(dtTeamMax.Rows[i]["Tmxt_BaodiTask"]) > 0)
{ newRow["保底完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamMax.Rows[i]["Tmxt_BaodiTask"]) * 100).ToString("0.00")); }
newRow["目标任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamMax.Rows[i]["Tmxt_TargetTask"].ToString().Trim());
newRow["目标完成情况"] = 0;
if (Convert.ToDecimal(dtTeamMax.Rows[i]["Tmxt_TargetTask"]) > 0)
{ newRow["目标完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamMax.Rows[i]["Tmxt_TargetTask"]) * 100).ToString("0.00")); }
newRow["冲刺任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamMax.Rows[i]["Tmxt_SprintTask"].ToString().Trim());
newRow["冲刺完成情况"] = 0;
if (Convert.ToDecimal(dtTeamMax.Rows[i]["Tmxt_SprintTask"]) > 0)
{ newRow["冲刺完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamMax.Rows[i]["Tmxt_SprintTask"]) * 100).ToString("0.00")); }
if (NewTable.Columns.Contains("婚纱单数"))
{
newRow["婚纱单数"] = decCompleteWeddingQuantity;
newRow["婚纱业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decCompleteWeddingAmount);
newRow["婚纱均价"] = 0;
if (decCompleteWeddingQuantity > 0)
{ newRow["婚纱均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompleteWeddingAmount / decCompleteWeddingQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("儿童单数"))
{
newRow["儿童单数"] = CompleteChildrenQuantity;
newRow["儿童业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompleteChildrenAmount);
newRow["儿童均价"] = 0;
if (CompleteChildrenQuantity > 0)
{ newRow["儿童均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompleteChildrenAmount / CompleteChildrenQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("写真单数"))
{
newRow["写真单数"] = CompletePortraitQuantity;
newRow["写真业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompletePortraitAmount);
newRow["写真均价"] = 0;
if (CompletePortraitQuantity > 0)
{ newRow["写真均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompletePortraitAmount / CompletePortraitQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("服务单数"))
{
newRow["服务单数"] = CompleteServiceQuantity;
newRow["服务业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompleteServiceAmount);
newRow["服务均价"] = 0;
if (CompleteServiceQuantity > 0)
{ newRow["服务均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompleteServiceAmount / CompleteServiceQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("婚庆单数"))
{
newRow["婚庆单数"] = CompleteWeddingCelebrationQuantity;
newRow["婚庆业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompleteWeddingCelebrationAmount);
newRow["婚庆均价"] = 0;
if (CompleteWeddingCelebrationQuantity > 0)
{ newRow["婚庆均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompleteWeddingCelebrationAmount / CompleteWeddingCelebrationQuantity).ToString("0.00")); }
}
NewTable.Rows.Add(newRow);
}
return NewTable;
}
///
/// 获取小组队的完成任务数据
///
///
///
DataTable GetTeamMinGroupBy(DataTable dtTeamMin, DataTable dtTeamPerson)
{
DataTable NewTable = new DataTable();
NewTable.Columns.Add("大队编号", typeof(string));
NewTable.Columns.Add("小组编号", typeof(string));
NewTable.Columns.Add("大队名称", typeof(string));
NewTable.Columns.Add("小组名称", typeof(string));
NewTable.Columns.Add("员工姓名", typeof(string));
NewTable.Columns.Add("完成任务", typeof(decimal));
NewTable.Columns.Add("保底任务", typeof(string));
NewTable.Columns.Add("保底完成情况", typeof(string));
NewTable.Columns.Add("目标任务", typeof(string));
NewTable.Columns.Add("目标完成情况", typeof(string));
NewTable.Columns.Add("冲刺任务", typeof(string));
NewTable.Columns.Add("冲刺完成情况", typeof(string));
if (dtTeamPerson.Columns.Contains("婚纱单数"))
{
NewTable.Columns.Add("婚纱单数", typeof(string));
NewTable.Columns.Add("婚纱业绩", typeof(string));
NewTable.Columns.Add("婚纱均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("儿童单数"))
{
NewTable.Columns.Add("儿童单数", typeof(string));
NewTable.Columns.Add("儿童业绩", typeof(string));
NewTable.Columns.Add("儿童均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("写真单数"))
{
NewTable.Columns.Add("写真单数", typeof(string));
NewTable.Columns.Add("写真业绩", typeof(string));
NewTable.Columns.Add("写真均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("服务单数"))
{
NewTable.Columns.Add("服务单数", typeof(string));
NewTable.Columns.Add("服务业绩", typeof(string));
NewTable.Columns.Add("服务均价", typeof(string));
}
if (dtTeamPerson.Columns.Contains("婚庆单数"))
{
NewTable.Columns.Add("婚庆单数", typeof(string));
NewTable.Columns.Add("婚庆业绩", typeof(string));
NewTable.Columns.Add("婚庆均价", typeof(string));
}
for (int i = 0; i < dtTeamMin.Rows.Count; i++)
{
decimal decCompletedTask = 0;
int decCompleteWeddingQuantity = 0;
decimal decCompleteWeddingAmount = 0;
int CompleteChildrenQuantity = 0;
decimal CompleteChildrenAmount = 0;
int CompletePortraitQuantity = 0;
decimal CompletePortraitAmount = 0;
int CompleteServiceQuantity = 0;
decimal CompleteServiceAmount = 0;
int CompleteWeddingCelebrationQuantity = 0;
decimal CompleteWeddingCelebrationAmount = 0;
DataRow[] dtRowTeamPerson = dtTeamPerson.Select("小组编号 = '" + dtTeamMin.Rows[i]["Tmit_Number"].ToString().Trim() + "'");
for (int j = 0; j < dtRowTeamPerson.Length; j++)
{
decCompletedTask += Convert.ToDecimal(dtRowTeamPerson[j]["完成任务"]);
if (NewTable.Columns.Contains("婚纱单数"))
{
decCompleteWeddingQuantity += Convert.ToInt32(dtRowTeamPerson[j]["婚纱单数"]);
decCompleteWeddingAmount += Convert.ToDecimal(dtRowTeamPerson[j]["婚纱业绩"]);
}
if (NewTable.Columns.Contains("儿童单数"))
{
CompleteChildrenQuantity += Convert.ToInt32(dtRowTeamPerson[j]["儿童单数"]);
CompleteChildrenAmount += Convert.ToDecimal(dtRowTeamPerson[j]["儿童业绩"]);
}
if (NewTable.Columns.Contains("写真单数"))
{
CompletePortraitQuantity += Convert.ToInt32(dtRowTeamPerson[j]["写真单数"]);
CompletePortraitAmount += Convert.ToDecimal(dtRowTeamPerson[j]["写真业绩"]);
}
if (NewTable.Columns.Contains("服务单数"))
{
CompleteServiceQuantity += Convert.ToInt32(dtRowTeamPerson[j]["服务单数"]);
CompleteServiceAmount += Convert.ToDecimal(dtRowTeamPerson[j]["服务业绩"]);
}
if (NewTable.Columns.Contains("婚庆单数"))
{
CompleteWeddingCelebrationQuantity += Convert.ToInt32(dtRowTeamPerson[j]["婚庆单数"]);
CompleteWeddingCelebrationAmount += Convert.ToDecimal(dtRowTeamPerson[j]["婚庆业绩"]);
}
}
DataRow newRow = NewTable.NewRow();
newRow["大队编号"] = dtTeamMin.Rows[i]["Tmit_TmxtNumber"].ToString().Trim();
newRow["小组编号"] = dtTeamMin.Rows[i]["Tmit_Number"].ToString().Trim();
newRow["大队名称"] = "";
newRow["小组名称"] = dtTeamMin.Rows[i]["Tmin_Name"].ToString().Trim();
newRow["员工姓名"] = "";
newRow["完成任务"] = decCompletedTask;
newRow["保底任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamMin.Rows[i]["Tmit_BaodiTask"].ToString().Trim());
newRow["保底完成情况"] = 0;
if (Convert.ToDecimal(dtTeamMin.Rows[i]["Tmit_BaodiTask"]) > 0)
{ newRow["保底完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamMin.Rows[i]["Tmit_BaodiTask"]) * 100).ToString("0.00")); }
newRow["目标任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamMin.Rows[i]["Tmit_TargetTask"].ToString().Trim());
newRow["目标完成情况"] = 0;
if (Convert.ToDecimal(dtTeamMin.Rows[i]["Tmit_TargetTask"]) > 0)
{ newRow["目标完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamMin.Rows[i]["Tmit_TargetTask"]) * 100).ToString("0.00")); }
newRow["冲刺任务"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dtTeamMin.Rows[i]["Tmit_SprintTask"].ToString().Trim());
newRow["冲刺完成情况"] = 0;
if (Convert.ToDecimal(dtTeamMin.Rows[i]["Tmit_SprintTask"]) > 0)
{ newRow["冲刺完成情况"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompletedTask / Convert.ToDecimal(dtTeamMin.Rows[i]["Tmit_SprintTask"]) * 100).ToString("0.00")); }
if (NewTable.Columns.Contains("婚纱单数"))
{
newRow["婚纱单数"] = decCompleteWeddingQuantity;
newRow["婚纱业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decCompleteWeddingAmount);
newRow["婚纱均价"] = 0;
if (decCompleteWeddingQuantity > 0)
{ newRow["婚纱均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((decCompleteWeddingAmount / decCompleteWeddingQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("儿童单数"))
{
newRow["儿童单数"] = CompleteChildrenQuantity;
newRow["儿童业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompleteChildrenAmount);
newRow["儿童均价"] = 0;
if (CompleteChildrenQuantity > 0)
{ newRow["儿童均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompleteChildrenAmount / CompleteChildrenQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("写真单数"))
{
newRow["写真单数"] = CompletePortraitQuantity;
newRow["写真业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompletePortraitAmount);
newRow["写真均价"] = 0;
if (CompletePortraitQuantity > 0)
{ newRow["写真均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompletePortraitAmount / CompletePortraitQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("服务单数"))
{
newRow["服务单数"] = CompleteServiceQuantity;
newRow["服务业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompleteServiceAmount);
newRow["服务均价"] = 0;
if (CompleteServiceQuantity > 0)
{ newRow["服务均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompleteServiceAmount / CompleteServiceQuantity).ToString("0.00")); }
}
if (NewTable.Columns.Contains("婚庆单数"))
{
newRow["婚庆单数"] = CompleteWeddingCelebrationQuantity;
newRow["婚庆业绩"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(CompleteWeddingCelebrationAmount);
newRow["婚庆均价"] = 0;
if (CompleteWeddingCelebrationQuantity > 0)
{ newRow["婚庆均价"] = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero((CompleteWeddingCelebrationAmount / CompleteWeddingCelebrationQuantity).ToString("0.00")); }
}
NewTable.Rows.Add(newRow);
}
return NewTable;
}
}
}