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

            mode = hfmode.Value.ToString();
            if (mode == "add")
            {
                msAngkutan cst = (from k in dss.msAngkutans
                                  where k.nama.ToString().Trim() == txtNrp.Text.Trim()
                                  select k).FirstOrDefault();
                if (cst == null)
                {
                    bool       b    = cmbUser.SelectedValue == "Aktif" ? true : false;
                    msAngkutan role = new msAngkutan();
                    //role.id = Convert.ToInt32(hdnRoleID.Value);
                    role.nama          = txtNrp.Text.Trim();
                    role.status        = b;
                    role.dibuatOleh    = userLoginID;
                    role.dibuatTanggal = DateTime.Now;
                    role.diubahOleh    = userLoginID;
                    role.diubahTanggal = DateTime.Now;

                    dss.msAngkutans.InsertOnSubmit(role);
                    dss.SubmitChanges();
                    dss.Dispose();
                    //clear_form();
                    notif.Text = "Data berhasil disimpan";
                    //fillGV("");
                }
                else
                {
                    notif.Text = "Angkutan sudah terdaftar";
                }
            }
            ////mode edit gadipake
            else if (mode == "edit")
            {
                msAngkutan cst = (from k in dss.msAngkutans
                                  where k.id.ToString().Trim() == (hdnRoleID.Value)
                                  select k).FirstOrDefault();

                bool b = cmbUser.SelectedValue == "Aktif" ? true : false;
                cst.id            = Convert.ToInt32(hdnRoleID.Value);
                cst.nama          = txtNrp.Text;
                cst.status        = b;
                cst.diubahOleh    = userLoginID;
                cst.diubahTanggal = DateTime.Now;

                //dss.msAngkutans.InsertOnSubmit(role);
                dss.SubmitChanges();
                dss.Dispose();
                notif.Text = "Data berhasil disimpan";
            }
            fillGV(txtFilterName.Text.Trim());
        }
Example #2
0
 private void fill_form(ref msAngkutan x, string status)
 {
     hdnRoleID.Value       = x.id.ToString();
     txtNrp.Text           = x.nama;
     cmbUser.SelectedValue = status;
     cmbUser.Visible       = true;
     //fillCmbUser(status);
     txtNrp.Enabled  = true;
     cmbUser.Enabled = true;
 }