Example #1
0
        protected void lbDelete_Click(object sender, EventArgs e)
        {
            dsSPDDataContext data   = new dsSPDDataContext();
            LinkButton       link   = (LinkButton)sender;
            GridViewRow      gv     = (GridViewRow)(link.NamingContainer);
            Label            costId = (Label)gv.FindControl("id");
            msRole           role   = data.msRoles.Where(f => f.id.ToString() == costId.Text).Single();

            data.msRoles.DeleteOnSubmit(role);
            data.SubmitChanges();
            data.Dispose();
            fillGV(txtFilterName.Text.Trim());
        }
Example #2
0
        private void fill_form(ref msRole x)
        {
            //txtRoleName.Text = x.namaRole;
            hdnRoleID.Value = x.id.ToString();
            txtNrp.Text     = string.Empty;
            fillCmbUser();
            txtPosisi.Text = x.namaRole;

            //txtRoleName.Enabled = false;
            txtNrp.Enabled    = true;
            cmbUser.Enabled   = true;
            txtPosisi.Enabled = false;
            //RequiredFieldValidator1.Visible = true;
            //RequiredFieldValidator2.Visible = true;
        }
Example #3
0
        //protected void lbEdit_Click(object sender, EventArgs e)
        //{
        //    dsSPDDataContext dss = new dsSPDDataContext();
        //    LinkButton link = (LinkButton)sender;
        //    GridViewRow gv = (GridViewRow)(link.NamingContainer);
        //    string nrp = gv.Cells[0].Text;
        //    Label costId = (Label)gv.FindControl("lblIdCost");
        //    //msCost cost = (from k in dss.msCosts where k.costId.ToString().Trim() == costId.Text.Trim() select k).FirstOrDefault();
        //    Label id = (Label)gv.FindControl("id");
        //    var x = (from m in dss.msRoles
        //             where m.id.ToString().Trim() == id.Text.Trim()
        //             select m).FirstOrDefault();
        //    fill_form(ref x);
        //    hfmode.Value = "edit";
        //    pnlForm.Visible = true;
        //    pnlGrid.Visible = false;
        //}

        protected void btnSimpan_Click(object sender, EventArgs e)
        {
            dsSPDDataContext dss  = new dsSPDDataContext();
            string           mode = "add";

            mode = hfmode.Value.ToString();
            if (mode == "add")
            {
                msRole cst = (from k in dss.msRoles
                              where k.namaRole.ToString().Trim() == txtPosisi.Text.Trim()
                              select k).FirstOrDefault();
                if (cst == null)
                {
                    msRole role = new msRole();
                    //role.id = Convert.ToInt32(hdnRoleID.Value);
                    role.namaRole      = txtPosisi.Text.Trim();
                    role.status        = true;
                    role.dibuatOleh    = userLoginID;
                    role.dibuatTanggal = DateTime.Now;
                    role.diubahOleh    = userLoginID;
                    role.diubahTanggal = DateTime.Now;

                    dss.msRoles.InsertOnSubmit(role);
                    dss.SubmitChanges();
                    dss.Dispose();
                    //clear_form();
                    notif.Text = "Data berhasil disimpan";
                    //fillGV("");
                }
                else
                {
                    notif.Text = "Nama Role atau Posisi sudah terdaftar";
                }
            }
            ////mode edit gadipake
            //else if (mode == "edit")
            //{

            //    msRole cst = (from k in dss.msRoles
            //                  where k.namaRole.ToString().Trim() == txtPosisi.Text.Trim()
            //                  select k).FirstOrDefault();
            //    if (cst == null)
            //    {
            //        msRole role = new msRole();
            //        //role.id = Convert.ToInt32(hdnRoleID.Value);
            //        role.namaRole = txtPosisi.Text.Trim();
            //        role.status = true;
            //        role.dibuatOleh = userLoginID;
            //        role.dibuatTanggal = DateTime.Now;
            //        role.diubahOleh = userLoginID;
            //        role.diubahTanggal = DateTime.Now;

            //        dss.msRoles.InsertOnSubmit(role);
            //        dss.SubmitChanges();
            //        dss.Dispose();
            //        notif.Text = "Data berhasil disimpan";
            //    }
            //    else
            //    {
            //        cst.id = Convert.ToInt32(hdnRoleID.Value);
            //        cst.namaRole = txtPosisi.Text.Trim();
            //        cst.diubahOleh = userLoginID;
            //        cst.diubahTanggal = DateTime.Now;
            //        dss.SubmitChanges();
            //        dss.Dispose();
            //        notif.Text = "Data berhasil disimpan";
            //    }
            //}
        }