protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //Load DataSource buat combo Kelompok Anggaran                
         ViewKelAnggaranCodeCombineNameCollection vkaccnc = new ViewKelAnggaranCodeCombineNameCollection();
         vkaccnc.LoadAll();
         cmbTransCode.DataSource = vkaccnc;
         cmbTransCode.DataTextField = "KaCodeName";
         cmbTransCode.DataValueField = "KaCode";
         cmbTransCode.DataBind();
         //Load DataSource buat combo Kas            
         KasCollection kasCollection = new KasCollection();
         kasCollection.LoadAll();
         cmbKasID.DataSource = kasCollection;
         cmbKasID.DataTextField = "KaName";
         cmbKasID.DataValueField = "KaCode";
         cmbKasID.DataBind();
         if (Request.QueryString["BKU_ID"] != null)
         {
             
                 long BkuID = 0;
                 if (long.TryParse(Request.QueryString["BKU_ID"], out BkuID))
                 {
                     Trans trans = new Trans();
                     if (trans.LoadByPrimaryKey(BkuID))
                     {
                         txtTransID.Text = trans.BkuId.ToString();
                         txtTransNumber.Text = trans.TransNumber;
                         dtpTransDate.SelectedDate = (DateTime)trans.TransDate;
                         cmbTransCode.SelectedValue = trans.KaCode;
                         cmbKasID.SelectedValue = trans.KasId;
                         txtDescription.Text = trans.Descript;
                         txtCekBG.Text = trans.CekBgNumber;
                         txtDebitAmount.Text = trans.DebitAmount.ToString();
                         txtCreditAmount.Text = trans.CreditAmount.ToString();
                     }
                 }
             
         }
         else
             txtTransNumber.Text = "{AUTO}";
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            //btnSAVE.Attributes.Add("onclick", "return validate()");
            if ((bool)HttpContext.Current.Session["_isEdit"] == false) // ADD
            {
                txtTransCode.Visible = false;
                cmbTransCODE.Visible = true;
                cmbTransCODE.Enabled = true;
                txtKasId.Visible = false;
                cmbKasID.Visible = true;

                //Auto Numbering
                txtTransCode.Text = "{auto}";

                //Trans Code
                //var transCodeQ = new KelAnggaranQuery();
                //transCodeQ.Select(transCodeQ.KaCode, transCodeQ.KaName, (transCodeQ.KaCode + " - " + transCodeQ.KaName).As("KA"));
                //KelAnggaranCollection kAColl = new KelAnggaranCollection()               
                //kAColl.Load(transCodeQ);               

                //var kQ = from k in rscm.Kel_anggarans
                //         where k.IS_DETAIL == true &&
                //         k.IS_KAS == false
                //         select new { k.KA_CODE, KaName = k.KA_NAME, complete = (k.KA_CODE + " - " +k.KA_NAME)};

                //ViewKelAnggaranCodeCombineName vkkk = new ViewKelAnggaranCodeCombineName();
                //vkkk.KaCode
                ViewKelAnggaranCodeCombineNameCollection vKA = new ViewKelAnggaranCodeCombineNameCollection();
                vKA.LoadAll();

                cmbTransCODE.Items.Clear();
                //cmbTransCODE.DataSource = kQ;
                //cmbTransCODE.DataTextField = "complete";
                //cmbTransCODE.DataValueField = "KA_CODE";
                cmbTransCODE.DataSource = vKA;
                cmbTransCODE.DataTextField = "KaCodeName";
                cmbTransCODE.DataValueField = "KaCode";
                cmbTransCODE.AllowCustomText = true;
                cmbTransCODE.MarkFirstMatch = true;
                //cmbTransCODE.DataBind();

                //Kas Code
                var kasCode = from kas in rscm.KAs
                              where kas.PERIODE_ID == (Int32)HttpContext.Current.Session["_periodeId"]
                              select kas;

                cmbKasID.DataSource = kasCode;
                cmbKasID.DataTextField = "KA_NAME";
                cmbKasID.DataValueField = "KA_CODE";
            }
            else //EDIT
            {
                //txtTransCode.Visible = true;
                txtTransCode.Visible = false;
                txtTransCode.ReadOnly = true;
                cmbTransCODE.Visible = true;
                cmbTransCODE.Enabled = true;
                var KelAngQ = from k in rscm.viewKelAnggaranCodeCombineNames
                              select k;

                cmbTransCODE.Items.Clear();
                //cmbTransCODE.DataSource = kQ;
                //cmbTransCODE.DataTextField = "complete";
                //cmbTransCODE.DataValueField = "KA_CODE";

                cmbTransCODE.DataSource = KelAngQ;
                cmbTransCODE.DataTextField = "KaCodeName";
                cmbTransCODE.DataValueField = "KA_CODE";
                cmbTransCODE.AllowCustomText = true;
                cmbTransCODE.MarkFirstMatch = true;

                cmbTransCODE.Visible = true;
                txtKasId.Visible = false;
                txtKasId.ReadOnly = true;

                //Kas Code
                var kasCode = from kas in rscm.KAs
                              where kas.PERIODE_ID == (Int32)HttpContext.Current.Session["_periodeId"]
                              select kas;

                cmbKasID.DataSource = kasCode;
                cmbKasID.DataTextField = "KA_NAME";
                cmbKasID.DataValueField = "KA_CODE";

                cmbKasID.Visible = true;
            }
        }