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

            mode = hfmode.Value.ToString();
            if (mode == "add")
            {
                msKeperluan cst = (from k in dss.msKeperluans
                                   where k.keperluan.ToString().Trim() == txtNrp.Text.Trim()
                                   select k).FirstOrDefault();
                if (cst == null)
                {
                    int         b    = cmbUser.SelectedValue == "Aktif" ? 1 : 0;
                    msKeperluan role = new msKeperluan();
                    //role.id = Convert.ToInt32(hdnRoleID.Value);
                    role.keperluan     = txtNrp.Text.Trim();
                    role.status        = b;
                    role.dibuatOleh    = userLoginID;
                    role.dibuatTanggal = DateTime.Now;
                    role.diubahOleh    = userLoginID;
                    role.diubahTanggal = DateTime.Now;

                    dss.msKeperluans.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")
            {
                msKeperluan cst = (from k in dss.msKeperluans
                                   where k.id.ToString().Trim() == hdnRoleID.Value
                                   select k).FirstOrDefault();

                int b = cmbUser.SelectedValue == "Aktif" ? 1 : 0;

                cst.id            = Convert.ToInt32(hdnRoleID.Value);
                cst.keperluan     = txtNrp.Text.Trim();
                cst.diubahOleh    = userLoginID;
                cst.diubahTanggal = DateTime.Now;
                cst.status        = b;
                dss.SubmitChanges();
                dss.Dispose();
                notif.Text = "Data berhasil disimpan";
            }
            fillGV(txtFilterName.Text.Trim());
        }
예제 #2
0
        private void fill_form(ref msKeperluan x, string status)
        {
            hdnRoleID.Value       = x.id.ToString();
            txtNrp.Text           = x.keperluan;
            cmbUser.SelectedValue = status;
            cmbUser.Visible       = true;

            //fillCmbUser(status);
            txtNrp.Enabled  = true;
            cmbUser.Enabled = true;
        }