protected void Button1_Click(object sender, EventArgs e) { InvAstRefTyp cn = new InvAstRefTyp(); cn.RefTyp_NmAr = Convert.ToString(TextBox2.Text); cn.RefTyp_NmEn = Convert.ToString(TextBox3.Text); cn.Prnt_RefTyp = 0; cn.Level_Status = Convert.ToInt16(RadioButtonList2.SelectedValue); int id = int.Parse(ViewState["id"].ToString()); /// to set level of new node /// if (cn.Prnt_RefTyp == null) { cn.Prnt_RefTyp = 0; } if (id == 0) { cn.Level_no = 1; } else { var result = db.InvAstRefTyp.Where(o => o.RefTyp_No == id).FirstOrDefault(); cn.Level_no = Convert.ToInt16(result.Level_no + 1); } if (cn.Cmp_No == 0) { cn.Cmp_No = 1; } if (cn.Actvty_No == 0) { cn.Actvty_No = 1; } //if (string.IsNullOrEmpty(DropDownList3.SelectedValue) || string.IsNullOrWhiteSpace(DropDownList3.SelectedValue)) { } //else // cn.Sup_No = short.Parse(DropDownList3.SelectedValue); //if (string.IsNullOrEmpty(RadioButtonList1.SelectedValue) || string.IsNullOrWhiteSpace(RadioButtonList1.SelectedValue)) { } //else // cn.Level_Status = Convert.ToInt16(RadioButtonList1.SelectedValue); cn.RefTyp_No = short.Parse(TextBox1.Text); db.InvAstRefTyp.Add(cn); db.SaveChanges(); load_tree(); Response.Redirect("reftypmain.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { //var id = int.Parse(Request.QueryString["no"]); //var cn = db.InvAstRefTyp.Find(id); InvAstRefTyp cn = new InvAstRefTyp(); cn.RefTyp_No = Convert.ToInt16(TextBox1.Text); cn.RefTyp_NmAr = TextBox2.Text; cn.RefTyp_NmEn = TextBox3.Text; cn.RefTyp_No = Convert.ToInt16(DropDownList1.SelectedValue); db.InvAstRefTyp.Add(cn); db.SaveChanges(); Response.Redirect("reftype.aspx"); }