private void CopyRecord()
    {
        //	copy record
        if (Request["copyid1"] != null || Request["editid1"] != null)
        {
            if (Request["copyid1"] != null)
            {
                item   = Data.PENGADAAN_LANGSUNG.FetchByID(Request["copyid1"]);
                isCopy = true;
            }
            else
            {
                item = Data.PENGADAAN_LANGSUNG.FetchByID(Request["editid1"]);
            }

            //	clear key fields
            defvalues["KODEPENGADAANLANGSUNG"] = item.KODEPENGADAANLANGSUNG;
        }
        else if (defvalues.Count == 0)
        {
        }

        if (inlineedit == ADD_MODE.ADD_ONTHEFLY)
        {
        }
    }
        public void Insert(
            String
            NAMAKEGIATAN
            ,
            String
            NAMAPAKET
            ,
            String
            KODESKPD
            ,
            DateTime
            TANGGALKONTRAK
            ,
            Decimal
            PAGU
            ,
            Decimal
            HPS
            ,
            Decimal
            NILAIKONTRAK
            ,
            String
            PEMENANG
            ,
            String
            KETERANGAN
            ,
            String
            PEJABATPENGADAAN
            ,
            String
            MENGETAHUI
            )
        {
            PENGADAAN_LANGSUNG item = new PENGADAAN_LANGSUNG();

            item.NAMAKEGIATAN     = NAMAKEGIATAN;
            item.NAMAPAKET        = NAMAPAKET;
            item.KODESKPD         = KODESKPD;
            item.TANGGALKONTRAK   = TANGGALKONTRAK;
            item.PAGU             = PAGU;
            item.HPS              = HPS;
            item.NILAIKONTRAK     = NILAIKONTRAK;
            item.PEMENANG         = PEMENANG;
            item.KETERANGAN       = KETERANGAN;
            item.PEJABATPENGADAAN = PEJABATPENGADAAN;
            item.MENGETAHUI       = MENGETAHUI;
            item.Save("");
        }
    private bool Init()
    {
        inlineedit = ((string)Request["editType"] == "inline");
        record_id  = (string)Request["recordID"];
        if (inlineedit)
        {
            templatefile = "PENGADAAN_LANGSUNG_inline_edit.aspx";
        }
        else
        {
            templatefile = "PENGADAAN_LANGSUNG_edit.aspx";
        }

        keys["KODEPENGADAANLANGSUNG"] = Request["editid1"];
        if (keys.Count > 1)
        {
            item = controller.FetchByManyID(keys);
        }
        else
        {
            item = Data.PENGADAAN_LANGSUNG.FetchByID(Request["editid1"]);
        }

        if (item != null)
        {
            bool editable = true;
            if (!editable)
            {
                output.Append("<p>" + "You don't have permissions to access this table" + " <a href=\"PENGADAAN_LANGSUNG_list.aspx?a=return\">back</a>");
                return(false);
            }
        }
        else
        {
            this.Server.Transfer("~/PENGADAAN_LANGSUNG_list.aspx?a=return");
        }

        return(true);
    }
    private void SaveData()
    {
        if (RequestAction != "edited")
        {
            item = new Data.PENGADAAN_LANGSUNG();
        }

        Data.PENGADAAN_LANGSUNG emptyItem = new Data.PENGADAAN_LANGSUNG();

        //	processing NAMAKEGIATAN - start
        if (!string.IsNullOrEmpty(Request["value_NAMAKEGIATAN"]))
        {
            item.NAMAKEGIATAN = Convert.ToString(Request["value_NAMAKEGIATAN"]);
        }
        else
        {
            item.NAMAKEGIATAN = emptyItem.NAMAKEGIATAN;
        }
        //	processing NAMAPAKET - start
        if (!string.IsNullOrEmpty(Request["value_NAMAPAKET"]))
        {
            item.NAMAPAKET = Convert.ToString(Request["value_NAMAPAKET"]);
        }
        else
        {
            item.NAMAPAKET = emptyItem.NAMAPAKET;
        }
        //	processing KODESKPD - start
        if (!string.IsNullOrEmpty(Request["value_KODESKPD"]))
        {
            item.KODESKPD = Convert.ToString(Request["value_KODESKPD"]);
        }
        else
        {
            item.KODESKPD = emptyItem.KODESKPD;
        }
        //	processing TANGGALKONTRAK - start
        if (!string.IsNullOrEmpty(Request["value_TANGGALKONTRAK"]))
        {
            item.TANGGALKONTRAK = Convert.ToDateTime(Request["value_TANGGALKONTRAK"]);
        }
        else
        {
            item.TANGGALKONTRAK = emptyItem.TANGGALKONTRAK;
        }
        //	processing PAGU - start
        if (!string.IsNullOrEmpty(Request["value_PAGU"]))
        {
            item.PAGU = Convert.ToDecimal(Request["value_PAGU"]);
        }
        else
        {
            item.PAGU = emptyItem.PAGU;
        }
        //	processing HPS - start
        if (!string.IsNullOrEmpty(Request["value_HPS"]))
        {
            item.HPS = Convert.ToDecimal(Request["value_HPS"]);
        }
        else
        {
            item.HPS = emptyItem.HPS;
        }
        //	processing NILAIKONTRAK - start
        if (!string.IsNullOrEmpty(Request["value_NILAIKONTRAK"]))
        {
            item.NILAIKONTRAK = Convert.ToDecimal(Request["value_NILAIKONTRAK"]);
        }
        else
        {
            item.NILAIKONTRAK = emptyItem.NILAIKONTRAK;
        }
        //	processing PEMENANG - start
        if (!string.IsNullOrEmpty(Request["value_PEMENANG"]))
        {
            item.PEMENANG = Convert.ToString(Request["value_PEMENANG"]);
        }
        else
        {
            item.PEMENANG = emptyItem.PEMENANG;
        }
        //	processing KETERANGAN - start
        if (!string.IsNullOrEmpty(Request["value_KETERANGAN"]))
        {
            item.KETERANGAN = Convert.ToString(Request["value_KETERANGAN"]);
        }
        else
        {
            item.KETERANGAN = emptyItem.KETERANGAN;
        }
        //	processing PEJABATPENGADAAN - start
        item.PEJABATPENGADAAN = UserName;

        //	processing MENGETAHUI - start
        if (!string.IsNullOrEmpty(Request["value_MENGETAHUI"]))
        {
            item.MENGETAHUI = Convert.ToString(Request["value_MENGETAHUI"]);
        }
        else
        {
            item.MENGETAHUI = emptyItem.MENGETAHUI;
        }
        //
        //item.KODEPENGADAANLANGSUNG =  Convert.ToString(Request["editid1"]);
        //
        string idx = string.Empty;

        idx = "1";
        item.KODEPENGADAANLANGSUNG = Convert.ToString(Request["editid" + idx]);
        bool abortSaving = false;

        if (!abortSaving)
        {
            item.MarkOld();
            item.Save();
            idx = "1";
            item.KODEPENGADAANLANGSUNG = Convert.ToString(Request["editid" + idx]);

            /*
             * if (!string.IsNullOrEmpty(Request["value_PEJABATPENGADAAN"])) {
             *      // save jenis pengadaan
             *      SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
             *      string ssql = "update PENGADAAN_LANGSUNG set JENISPENGADAAN = '" + Convert.ToString(Request["value_PEJABATPENGADAAN"]) + "' where KODEPENGADAANLANGSUNG = '" + item.KODEPENGADAANLANGSUNG + "';";
             *      SqlCommand myCommand = new SqlCommand();
             *      myCommand.CommandText = ssql;
             *      myCommand.CommandType = CommandType.Text;
             *      myCommand.Connection = myConnection;
             *      myConnection.Open();
             *
             *      int recAffected = 0;
             *      recAffected = myCommand.ExecuteNonQuery();
             *
             *      myCommand.Dispose();
             *      myConnection.Close();
             *      myConnection.Dispose();
             *      // end of save jenis pengadaan
             * }
             */
            ShowSuccessMessage();
        }
    }
    private void SaveData()
    {
        item = new Data.PENGADAAN_LANGSUNG();
        //	processing KODEPENGADAANLANGSUNG - start
        SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        string        ssql         = "select count(*), year(getdate()) from pengadaan_langsung where year(tanggalkontrak)=year(getdate());";
        SqlCommand    myCommand    = new SqlCommand();

        myCommand.CommandText = ssql;
        myCommand.CommandType = CommandType.Text;
        myCommand.Connection  = myConnection;
        myConnection.Open();
        SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

        int iPbjCtr = 0;
        int iYear   = 0;

        while (myReader.Read())
        {
            iPbjCtr = Convert.ToInt32(myReader.GetValue(0).ToString()) + 1;
            iYear   = Convert.ToInt32(myReader.GetValue(1).ToString());
        }
        myReader.Close();
        item.KODEPENGADAANLANGSUNG = Convert.ToString(Request["value_KODESKPD"]).Replace(".", "") + ".L" + Convert.ToString(iYear) + Convert.ToString(iPbjCtr);

        //	processing NAMAKEGIATAN - start
        if (!string.IsNullOrEmpty(Request["value_NAMAKEGIATAN"]))
        {
            item.NAMAKEGIATAN = Convert.ToString(Request["value_NAMAKEGIATAN"]);
        }
        //	processing NAMAPAKET - start
        if (!string.IsNullOrEmpty(Request["value_NAMAPAKET"]))
        {
            item.NAMAPAKET = Convert.ToString(Request["value_NAMAPAKET"]);
        }
        //	processing KODESKPD - start
        if (!string.IsNullOrEmpty(Request["value_KODESKPD"]))
        {
            item.KODESKPD = Convert.ToString(Request["value_KODESKPD"]);
        }
        //	processing TANGGALKONTRAK - start
        if (!string.IsNullOrEmpty(Request["value_TANGGALKONTRAK"]))
        {
            item.TANGGALKONTRAK = Convert.ToDateTime(Request["value_TANGGALKONTRAK"]);
        }
        //	processing PAGU - start
        if (!string.IsNullOrEmpty(Request["value_PAGU"]))
        {
            item.PAGU = Convert.ToDecimal(Request["value_PAGU"]);
        }
        //	processing HPS - start
        if (!string.IsNullOrEmpty(Request["value_HPS"]))
        {
            item.HPS = Convert.ToDecimal(Request["value_HPS"]);
        }
        //	processing NILAIKONTRAK - start
        if (!string.IsNullOrEmpty(Request["value_NILAIKONTRAK"]))
        {
            item.NILAIKONTRAK = Convert.ToDecimal(Request["value_NILAIKONTRAK"]);
        }
        //	processing PEMENANG - start
        if (!string.IsNullOrEmpty(Request["value_PEMENANG"]))
        {
            item.PEMENANG = Convert.ToString(Request["value_PEMENANG"]);
        }
        //	processing KETERANGAN - start
        if (!string.IsNullOrEmpty(Request["value_KETERANGAN"]))
        {
            item.KETERANGAN = Convert.ToString(Request["value_KETERANGAN"]);
        }
        //	processing PEJABATPENGADAAN - start
        item.PEJABATPENGADAAN = UserName;

        //	processing MENGETAHUI - start
        if (!string.IsNullOrEmpty(Request["value_MENGETAHUI"]))
        {
            item.MENGETAHUI = Convert.ToString(Request["value_MENGETAHUI"]);
        }
        bool abortSaving = false;


        if (!abortSaving)
        {
            item.Save();

            // save jenis pengadaan
            ssql                  = "update PENGADAAN_LANGSUNG set JENISPENGADAAN = '" + Convert.ToString(Request["value_PEJABATPENGADAAN"]) + "' where KODEPENGADAANLANGSUNG = '" + item.KODEPENGADAANLANGSUNG + "';";
            myCommand             = new SqlCommand();
            myCommand.CommandText = ssql;
            myCommand.CommandType = CommandType.Text;
            myCommand.Connection  = myConnection;
            myConnection.Open();

            int recAffected = 0;
            recAffected = myCommand.ExecuteNonQuery();

            myCommand.Dispose();
            myConnection.Close();
            myConnection.Dispose();
            // end of save jenis pengadaan

            ShowSuccessMessage();
        }
    }