//Buraya Kadar Firmaları seçtikten sonra Şubeleri Daha Sonra Bölümleri Seçmemizi Sağladık protected void rpWorkingList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Update") { using (db = new novartz_stajyer1Entities()) { Guid id = Guid.Parse(e.CommandArgument.ToString()); VW_FIRMDEPARTMENTMEMBER departmentMember = db.VW_FIRMDEPARTMENTMEMBER.SingleOrDefault(t => t.ID == id); RECID = departmentMember.ID; hdnDepartmentID.Value = e.CommandArgument.ToString(); lblFirmUpdate.Text = departmentMember.FIRMNAME; lblPersonel.Text = departmentMember.FULLNAME; lblBranchUpdate.Text = departmentMember.FIRMBRANCHNAME; FillDrp(DrpDepartmentUpdate, db.VW_FIRMDEPARTMENT.Where(t => t.FIRMBRANCHID == departmentMember.FIRMBRANCHID).ToList(), "ID", "NAME", "Seçiniz"); DrpDepartmentUpdate.SelectedValue = departmentMember.FIRMDEPARTMENTID.ToString();//Drop seçileceği zaman; seçilmeden önceki hangi bölüme ait ise o bölüm seçili olarak gelmesini sağlıyor. departmentMember.ISACTIVE = dropmdlcd.SelectedValue == "0"; } ScriptManager.RegisterStartupScript(this, GetType(), "", "OpenModal()", true); upModalUpdate.Update(); } else if (e.CommandName == "Delete")//Eğer buton Delete butonu ise bunu yapacak. { using (db = new novartz_stajyer1Entities()) { Guid id = Guid.Parse(e.CommandArgument.ToString()); FIRMDEPARTMENTMEMBER department = db.FIRMDEPARTMENTMEMBER.SingleOrDefault(t => t.MEMBERID == id); //SinglorDefault tek veri çekmek için kulladığımız deyim //FIRMBRANCH test = (from t in db.FIRMBRANCH where t.ID == id select t).SingleOrDefault(); db.FIRMDEPARTMENTMEMBER.Remove(department); //silmek için kullandın removeyi db.SaveChanges(); FillDepartment(); UpdatePanel.Update(); } } }
protected void btnSaveFirmDepartmentMember_Click(object sender, EventArgs e)//Yeni çalışan ekle kısmını yaptım kayıt yapıyor seçilen kısıma.. { if (ValidateRecord()) { Guid id = Guid.NewGuid(); MEMBER member = null; using (db = new novartz_stajyer1Entities()) { member = new MEMBER { NAME = txtmdlName.Text, SURNAME = txtmdlSurname.Text, LOGINNAME = txtmdlMail.Text, BIRDDATE = Convert.ToDateTime(txtmdlBirtday.Text), PHONE = txtmdlPhone.Text, PASWORD = txtmdlPassword.Text, GENDER = Convert.ToBoolean(drpmdlGender.SelectedValue == "1"),//Bayan ise true olarak çalışıyor TYPEMEMBERID = Convert.ToByte(drpmdltypmember.SelectedValue), CANLOGIN = true, ID = id }; db.MEMBER.Add(member); db.SaveChanges(); }; if (drpmdltypmember.SelectedValue == "3") { FIRMRESPONSIBLE rsp = null; using (db = new novartz_stajyer1Entities()) { Guid id3 = Guid.NewGuid(); rsp = new FIRMRESPONSIBLE { ID = id3, FIRMID = Guid.Parse(DrpFirm.SelectedValue), MEMBERID = id }; db.FIRMRESPONSIBLE.Add(rsp); db.SaveChanges(); } } FIRMDEPARTMENTMEMBER rec = null; using (db = new novartz_stajyer1Entities()) { Guid id2 = Guid.NewGuid(); rec = new FIRMDEPARTMENTMEMBER { ID = id2, FIRMDEPARTMENTID = Guid.Parse(DrpDepartment.SelectedValue), ISACTIVE = dropmdlcd.SelectedValue == "1", MEMBERID = id }; db.FIRMDEPARTMENTMEMBER.Add(rec); db.SaveChanges(); }; MessageBox("İşleminiz Başarılı"); } }
protected void btnUpdateSaveServer_Click(object sender, EventArgs e)//Güncelleme Bölümünde kaydetme işlemini yaptık... { using (db = new novartz_stajyer1Entities()) { FIRMDEPARTMENTMEMBER rec = db.FIRMDEPARTMENTMEMBER.SingleOrDefault(t => t.ID == RECID); rec.FIRMDEPARTMENTID = Guid.Parse(DrpDepartmentUpdate.SelectedValue); rec.ISACTIVE = Convert.ToBoolean(DrpcdUpdate.SelectedValue == "1"); db.SaveChanges(); FillDepartment(); UpdatePanel.Update(); } }
protected void btnAddDepartmentMember_Click(object sender, EventArgs e) { if (ValidateDepartmentMember()) { Guid id = Guid.NewGuid(); MEMBER member = null; using (db = new novartz_stajyer1Entities()) { member = new MEMBER { NAME = txtDepMemberName.Text, SURNAME = txtDepMemberSurname.Text, LOGINNAME = txtDepMemberEmail.Text, BIRDDATE = Convert.ToDateTime(txtDepMemberBirthday.Text), PHONE = txtDepMemberTelephone.Text, PASWORD = txtDepMemberPassword.Text, CANLOGIN = true, GENDER = drpDepMemberGender.SelectedValue == "1", TYPEMEMBERID = 2, ID = id, }; db.MEMBER.Add(member); db.SaveChanges(); }; FIRMDEPARTMENTMEMBER rec = null; using (db = new novartz_stajyer1Entities()) { Guid id2 = Guid.NewGuid(); rec = new FIRMDEPARTMENTMEMBER { ID = id2, FIRMDEPARTMENTID = Guid.Parse(drpDepMemberDepartment.SelectedValue), ISACTIVE = drpDepMemberStatus.SelectedValue == "1", MEMBERID = id }; db.FIRMDEPARTMENTMEMBER.Add(rec); db.SaveChanges(); InitPage(false); upDepartmentMember.Update(); }; MessageBox("İşleminiz Başarılı"); } }
protected void rpFirmDepMemberList_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "Update": if (!string.IsNullOrEmpty(e.CommandArgument.ToString())) { using (db = new novartz_stajyer1Entities()) { Guid selectedMemberID = Guid.Parse(e.CommandArgument.ToString()); lblDepartmentMemberIsUpdate.Text = "Güncelleyiniz"; VW_FIRMDEPARTMENTMEMBER rec = db.VW_FIRMDEPARTMENTMEMBER.SingleOrDefault(t => t.ID == selectedMemberID); if (rec != null) { FillDrp(drpDepMemberBranch, db.FIRMBRANCH.Where(d => d.FIRMID == RECID).ToList(), "ID", "NAME", "Şubesizler"); if (rec.FIRMBRANCHID.HasValue) { drpDepMemberBranch.SelectedValue = rec.FIRMBRANCHID.Value.ToString(); } drpDepMemberBranch_SelectedIndexChanged(null, null); drpDepMemberDepartment.SelectedValue = rec.FIRMDEPARTMENTID.ToString(); txtDepMemberTelephone.Text = rec.PHONE; txtDepMemberName.Text = rec.NAME; txtDepMemberSurname.Text = rec.SURNAME; txtDepMemberBirthday.Text = rec.BIRDDATE.ToString(); if (rec.GENDER.HasValue) { drpDepMemberGender.SelectedValue = rec.GENDER.Value ? "1" : "0"; } drpDepMemberStatus.SelectedValue = rec.ISACTIVE ? "1" : "0"; drpDepMemEmail.Text = rec.LOGINNAME; DEPARTMENTMEMBERID = selectedMemberID; ScriptManager.RegisterStartupScript(this, this.GetType(), "OpenDepartmentMemberModal", "$('#mdlNewDepartmentMember').modal('show');", true); upMdlNewDepartmentMember.Update(); } } } break; case "Delete": // OLMADI BU KISIMM!!! using (db = new novartz_stajyer1Entities()) { Guid selectedMemberID = Guid.Parse(e.CommandArgument.ToString()); FIRMDEPARTMENTMEMBER rec = db.FIRMDEPARTMENTMEMBER.SingleOrDefault(t => t.ID == selectedMemberID); if (rec != null) { //hata kontrolü yap 547 db.FIRMDEPARTMENTMEMBER.Remove(rec); db.SaveChanges(); // InitPage(false); // upMdlNewDepartmentMember.Update(); } MEMBER mem = db.MEMBER.SingleOrDefault(t => t.ID == rec.MEMBERID); if (mem != null) { db.MEMBER.Remove(mem); db.SaveChanges(); InitPage(false); upDepartmentMember.Update(); } } break; } }