Пример #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid && !string.IsNullOrEmpty(this.hdnSchId.Value))
        {
            int schoolSublevelId = Public.ToInt(this.drpSublevel.SelectedValue.Split('|')[0]);
            for (int i = 1; i < this.drpStuff_1.Items.Count; i++)
            {
                db.SchoolClothes.DeleteAllOnSubmit<SupplySystem.SchoolClothe>(from sc in db.SchoolClothes join cc in db.CycleClothes on sc.CycleClotheID equals cc.CycleClotheID where sc.SchoolSubLevelID == schoolSublevelId && sc.CycleClotheID == int.Parse(this.drpStuff_1.Items[i].Value) select sc);
            }

            using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
            {
                db.SubmitChanges();
                int cycleClotheId1 = Public.ToInt(this.drpStuff_1.SelectedValue);
                int cycleClotheId2 = Public.ToInt(this.drpStuff_2.SelectedValue);
                int cycleClotheId3 = Public.ToInt(this.drpStuff_3.SelectedValue);
                int cycleClotheId4 = Public.ToInt(this.drpStuff_4.SelectedValue);
                int cycleClotheId5 = Public.ToInt(this.drpStuff_5.SelectedValue);

                List<SupplySystem.SchoolClothe> clothesList = new List<SupplySystem.SchoolClothe>();
                TextBox txtStudentName = null;
                CheckBox chkGood_1 = null;
                CheckBox chkGood_2 = null;
                CheckBox chkGood_3 = null;
                CheckBox chkGood_4 = null;
                CheckBox chkGood_5 = null;
                for (int i = 0; i < this.grdStudentClothes.Rows.Count; i++)
                {
                    txtStudentName = (TextBox)this.grdStudentClothes.Rows[i].FindControl("txtStudentName");
                    chkGood_1 = (CheckBox)this.grdStudentClothes.Rows[i].FindControl("chkGood_1");
                    chkGood_2 = (CheckBox)this.grdStudentClothes.Rows[i].FindControl("chkGood_2");
                    chkGood_3 = (CheckBox)this.grdStudentClothes.Rows[i].FindControl("chkGood_3");
                    chkGood_4 = (CheckBox)this.grdStudentClothes.Rows[i].FindControl("chkGood_4");
                    chkGood_5 = (CheckBox)this.grdStudentClothes.Rows[i].FindControl("chkGood_5");

                    if (!string.IsNullOrEmpty(txtStudentName.Text))
                    {
                        if (this.drpStuff_1.SelectedIndex > 0 && chkGood_1.Checked)
                        {
                            SupplySystem.SchoolClothe schoolClothe = clothesList.SingleOrDefault<SupplySystem.SchoolClothe>(sc => sc.CycleClotheID == cycleClotheId1);
                            if (schoolClothe == null)
                            {
                                schoolClothe = new SupplySystem.SchoolClothe { CycleClotheID = Public.ToShort(this.drpStuff_1.SelectedValue), SchoolSubLevelID = schoolSublevelId, SubmitDate = DateTime.Now };
                                clothesList.Add(schoolClothe);
                            }
                            schoolClothe.StudentClothes.Add(new SupplySystem.StudentClothe { StudentName = txtStudentName.Text, ClotheCount = 1 });
                        }

                        if (this.drpStuff_2.SelectedIndex > 0 && chkGood_2.Checked)
                        {
                            SupplySystem.SchoolClothe schoolClothe = clothesList.SingleOrDefault<SupplySystem.SchoolClothe>(sc => sc.CycleClotheID == cycleClotheId2);
                            if (schoolClothe == null)
                            {
                                schoolClothe = new SupplySystem.SchoolClothe { CycleClotheID = Public.ToShort(this.drpStuff_2.SelectedValue), SchoolSubLevelID = schoolSublevelId, SubmitDate = DateTime.Now };
                                clothesList.Add(schoolClothe);
                            }
                            schoolClothe.StudentClothes.Add(new SupplySystem.StudentClothe { StudentName = txtStudentName.Text, ClotheCount = 1 });
                        }

                        if (this.drpStuff_3.SelectedIndex > 0 && chkGood_3.Checked)
                        {
                            SupplySystem.SchoolClothe schoolClothe = clothesList.SingleOrDefault<SupplySystem.SchoolClothe>(sc => sc.CycleClotheID == cycleClotheId3);
                            if (schoolClothe == null)
                            {
                                schoolClothe = new SupplySystem.SchoolClothe { CycleClotheID = Public.ToShort(this.drpStuff_3.SelectedValue), SchoolSubLevelID = schoolSublevelId, SubmitDate = DateTime.Now };
                                clothesList.Add(schoolClothe);
                            }
                            schoolClothe.StudentClothes.Add(new SupplySystem.StudentClothe { StudentName = txtStudentName.Text, ClotheCount = 1 });
                        }

                        if (this.drpStuff_4.SelectedIndex > 0 && chkGood_4.Checked)
                        {
                            SupplySystem.SchoolClothe schoolClothe = clothesList.SingleOrDefault<SupplySystem.SchoolClothe>(sc => sc.CycleClotheID == cycleClotheId4);
                            if (schoolClothe == null)
                            {
                                schoolClothe = new SupplySystem.SchoolClothe { CycleClotheID = Public.ToShort(this.drpStuff_4.SelectedValue), SchoolSubLevelID = schoolSublevelId, SubmitDate = DateTime.Now };
                                clothesList.Add(schoolClothe);
                            }
                            schoolClothe.StudentClothes.Add(new SupplySystem.StudentClothe { StudentName = txtStudentName.Text, ClotheCount = 1 });
                        }

                        if (this.drpStuff_5.SelectedIndex > 0 && chkGood_5.Checked)
                        {
                            SupplySystem.SchoolClothe schoolClothe = clothesList.SingleOrDefault<SupplySystem.SchoolClothe>(sc => sc.CycleClotheID == cycleClotheId5);
                            if (schoolClothe == null)
                            {
                                schoolClothe = new SupplySystem.SchoolClothe { CycleClotheID = Public.ToShort(this.drpStuff_5.SelectedValue), SchoolSubLevelID = schoolSublevelId, SubmitDate = DateTime.Now };
                                clothesList.Add(schoolClothe);
                            }
                            schoolClothe.StudentClothes.Add(new SupplySystem.StudentClothe { StudentName = txtStudentName.Text, ClotheCount = 1 });
                        }
                    }
                }

                if (clothesList.Count > 0)
                {
                    db.SchoolClothes.InsertAllOnSubmit(clothesList);
                    db.SubmitChanges();
                    scope.Complete();
                    this.lblMessage.Text = Public.SUCCESSMESSAGE;
                }
            }
        }
    }
Пример #2
0
		private void detach_SchoolClothes(SchoolClothe entity)
		{
			this.SendPropertyChanging();
			entity.SchoolSubLevel = null;
		}
Пример #3
0
		private void detach_SchoolClothes(SchoolClothe entity)
		{
			this.SendPropertyChanging();
			entity.CycleClothe = null;
		}
Пример #4
0
 partial void DeleteSchoolClothe(SchoolClothe instance);
Пример #5
0
 partial void UpdateSchoolClothe(SchoolClothe instance);
Пример #6
0
 partial void InsertSchoolClothe(SchoolClothe instance);