private void Lvw_Plan_ItemCheck(object sender, ItemCheckEventArgs e) { Plan plan = new Plan(); this.CountAppDataDetails(); DataSet npCountByPlanID = plan.GetNpCountByPlanID(this.Lvw_Plan.Items[e.Index].SubItems[1].Text); if ((npCountByPlanID != null) && (npCountByPlanID.Tables[0].Rows.Count > 0)) { for (int i = 0; i < npCountByPlanID.Tables[0].Rows.Count; i++) { string key = npCountByPlanID.Tables[0].Rows[i]["NPType"].ToString(); if (e.NewValue == CheckState.Checked) { if (this.G_SelectNPCount.ContainsKey(npCountByPlanID.Tables[0].Rows[i]["NPType"].ToString())) { this.G_SelectNPCount[key] = Convert.ToString((int) (int.Parse(this.G_SelectNPCount[key].ToString()) + int.Parse(npCountByPlanID.Tables[0].Rows[i]["Count"].ToString()))); } else { this.G_SelectNPCount.Add(key, 0); this.G_SelectNPCount[key] = Convert.ToString((int) (int.Parse(this.G_SelectNPCount[key].ToString()) + int.Parse(npCountByPlanID.Tables[0].Rows[i]["Count"].ToString()))); } this.G_SelectTotal += int.Parse(npCountByPlanID.Tables[0].Rows[i]["Count"].ToString()); this.G_SelectPlan++; } else { if (this.G_SelectNPCount.ContainsKey(npCountByPlanID.Tables[0].Rows[i]["NPType"].ToString())) { this.G_SelectNPCount[key] = Convert.ToString((int) (int.Parse(this.G_SelectNPCount[key].ToString()) - int.Parse(npCountByPlanID.Tables[0].Rows[i]["Count"].ToString()))); } this.G_SelectTotal -= int.Parse(npCountByPlanID.Tables[0].Rows[i]["Count"].ToString()); this.G_SelectPlan--; } } } this.ShowCountInLabel(); }
private void CountAppDataDetails() { Plan plan = new Plan(); this.G_SelectPlan = 0; this.G_SelectTotal = 0; this.G_Total = 0; this.G_TotalNPCount.Clear(); this.G_SelectNPCount.Clear(); for (int i = 0; i < this.Lvw_Plan.Items.Count; i++) { DataSet npCountByPlanID = plan.GetNpCountByPlanID(this.Lvw_Plan.Items[i].SubItems[1].Text); if ((npCountByPlanID != null) && (npCountByPlanID.Tables[0].Rows.Count > 0)) { for (int j = 0; j < npCountByPlanID.Tables[0].Rows.Count; j++) { string key = npCountByPlanID.Tables[0].Rows[j]["NPType"].ToString(); if (this.G_TotalNPCount.ContainsKey(npCountByPlanID.Tables[0].Rows[j]["NPType"].ToString())) { this.G_TotalNPCount[key] = Convert.ToString((int) (int.Parse(this.G_TotalNPCount[key].ToString()) + int.Parse(npCountByPlanID.Tables[0].Rows[j]["Count"].ToString()))); } else { this.G_TotalNPCount.Add(key, 0); this.G_TotalNPCount[key] = Convert.ToString((int) (int.Parse(this.G_TotalNPCount[key].ToString()) + int.Parse(npCountByPlanID.Tables[0].Rows[j]["Count"].ToString()))); } this.G_Total += int.Parse(npCountByPlanID.Tables[0].Rows[j]["Count"].ToString()); if (this.Lvw_Plan.Items[i].Checked) { if (this.G_SelectNPCount.ContainsKey(npCountByPlanID.Tables[0].Rows[j]["NPType"].ToString())) { this.G_SelectNPCount[key] = Convert.ToString((int) (int.Parse(this.G_SelectNPCount[key].ToString()) + int.Parse(npCountByPlanID.Tables[0].Rows[j]["Count"].ToString()))); } else { this.G_SelectNPCount.Add(key, 0); this.G_SelectNPCount[key] = Convert.ToString((int) (int.Parse(this.G_SelectNPCount[key].ToString()) + int.Parse(npCountByPlanID.Tables[0].Rows[j]["Count"].ToString()))); } this.G_SelectTotal += int.Parse(npCountByPlanID.Tables[0].Rows[j]["Count"].ToString()); this.G_SelectPlan++; } } } } }