protected void Btn_Sodor_Click(object sender, EventArgs e) { string Str_Nationacode = TxtNationalcode.Text; if (Lts_Inherited.Tb_CertPays.SingleOrDefault(n => n.xDedId_fk == Tb_Dead2.xDedId_pk) == null) { Tb_CertPay1 = new Tb_CertPay(); Tb_CertPay1.xCrtRegNo = Txt_CrtNo.Text; Tb_CertPay1.xCrtRegDate = Ddl_Year.Text + "/" + Ddl_Mounth.Text + "/" + Ddl_day.Text; Tb_CertPay1.xDedId_fk = Tb_Dead2.xDedId_pk; Lts_Inherited.Tb_CertPays.InsertOnSubmit(Tb_CertPay1); try { Lts_Inherited.SubmitChanges(); Session["Nationalcode"] = Str_Nationacode; Response.Redirect("~/Rpt_Pay.aspx", false); } catch (Exception ex) { Lbl_Msg.Text = "Error!" + ex.ToString(); Lbl_Msg.ForeColor = System.Drawing.Color.Red; Lbl_Msg.Visible = true; } } else { Tb_File Tb_File1 = Lts_Inherited.Tb_Files.Where(n => n.xDedId_fk == Tb_Dead2.xDedId_pk).First(); Lbl_Msg.Text = "برای این شخص قبلا گواهی صادر گردیده است!:" + "حوزه:" + Tb_File1.xHozeh + "---" + "کلاسه:" + Tb_File1.xClass; Lbl_Msg.ForeColor = System.Drawing.Color.Red; Lbl_Msg.Visible = true; } }
protected void Btn_Sodor_Click(object sender, EventArgs e) { if (Txt_Klasse.Text.Trim() == "") { Alarm.ShowMesseage("!کلاسه را وارد کنید", this.Page); return; } if (Chk_Heirs.Items.Count == 0) { Lbl_Msg.Text = "وراث را ثبت نمایید!"; Lbl_Msg.ForeColor = System.Drawing.Color.Red; Lbl_Msg.Visible = true; return; } if (Chk_Estates.Items.Count == 0) { Lbl_Msg.Text = "دارایی ها را ثبت نمایید!"; Lbl_Msg.ForeColor = System.Drawing.Color.Red; Lbl_Msg.Visible = true; return; } if (Lts_Inherited.Tb_Applies.SingleOrDefault(n => n.Tb_Dead == Tb_Dead1) == null) { Lbl_Msg.Text = "اطلاعات فرم درخواست ثبت نگردیده است!"; Lbl_Msg.ForeColor = System.Drawing.Color.Red; Lbl_Msg.Visible = true; return; } bool bol_Flag = false; foreach (ListItem HrsItem in Chk_Heirs.Items) { if (HrsItem.Selected) { foreach (ListItem EstItem in Chk_Estates.Items) { if (EstItem.Selected) { if (Lts_Inherited.Tb_CertPersonPays.SingleOrDefault(n => n.xPrsId_fk == int.Parse(HrsItem.Value) && n.xEstId_fk == int.Parse(EstItem.Value)) != null) { bol_Flag = true; break; } } } } } if (bol_Flag) { Tb_File Tb_File1 = Lts_Inherited.Tb_Files.Where(n => n.xDedId_fk == Tb_Dead1.xDedId_pk).First(); Lbl_Msg.Text = "گواهی برای اشخاص انتخاب شده با دارایی های انتخابی صادر گردیده است" + "!"; Lbl_Msg.ForeColor = System.Drawing.Color.Red; Lbl_Msg.Visible = true; return; } string Str_Nationacode = Tb_Dead1.xDedNationalCode; Tb_CertPay1 = new Tb_CertPay(); Tb_CertPay1.xCrtRegNo = Txt_CrtNo.Text; Tb_CertPay1.xCrtRegDate = Ddl_Year.Text + "/" + Ddl_Mounth.Text + "/" + Ddl_day.Text; Tb_CertPay1.xDedId_fk = Tb_Dead1.xDedId_pk; Tb_CertPay1.xCrtTo = Txt_Nahad.Text.Trim(); Lts_Inherited.Tb_CertPays.InsertOnSubmit(Tb_CertPay1); foreach (ListItem ItemHeir in Chk_Heirs.Items) { if (ItemHeir.Selected) { foreach (ListItem ItemEstate in Chk_Estates.Items) { if (ItemEstate.Selected) { Tb_CertPersonPay Tb_CertPersonPay1 = new Tb_CertPersonPay(); Tb_CertPersonPay1.Tb_CertPay = Tb_CertPay1; Tb_CertPersonPay1.xPrsId_fk = int.Parse(ItemHeir.Value); Tb_CertPersonPay1.xEstId_fk = int.Parse(ItemEstate.Value); Lts_Inherited.Tb_CertPersonPays.InsertOnSubmit(Tb_CertPersonPay1); } } } } try { Lts_Inherited.SubmitChanges(); } catch (Exception ex) { Lbl_Msg.Text = "Error!" + ex.ToString(); Lbl_Msg.ForeColor = System.Drawing.Color.Red; Lbl_Msg.Visible = true; return; } Ddl_day.Text = Ddl_Mounth.Text = Txt_CrtNo.Text = ""; foreach (ListItem item in Chk_Estates.Items) { item.Selected = false; } foreach (ListItem item in Chk_Heirs.Items) { item.Selected = false; } Lbl_Msg.Text = "گواهی صادر گردید" + "!"; Lbl_Msg.ForeColor = System.Drawing.Color.Green; Lbl_Msg.Visible = true; List <Tb_CertPay> Lst_Cert = Lts_Inherited.Tb_CertPays.Where(n => n.xDedId_fk == Tb_Dead1.xDedId_pk).ToList(); Gvw_CertPay.DataSource = Lst_Cert; Gvw_CertPay.DataBind(); Gvw_CertPay.Visible = true; MainTable.Rows[7].Cells[0].Visible = true; }