protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            RscmBkuDataContext rscmdc = new RscmBkuDataContext();
            var kelAg = from k in rscmdc.Kel_anggarans
                        join p in rscmdc.ParentId_DataSource_ComboBoxes on k.PARENT_CODE equals p.KA_CODE
                        where (k.IS_KAS == false)
                        select new { KaId = k.KA_ID, KaCode = k.KA_CODE, KaName = k.KA_NAME, Parent = p.KA_NAME, GtCode = k.GT_CODE, Prefix = k.PREFIX, KaLevel=k.KA_LEVEL, Type=k.TYPE, IsDetail=k.IS_DETAIL, IsActive=k.IS_ACTIVE, IsKas=k.IS_KAS };


            KelAnggaranCollection kaColl = new KelAnggaranCollection();
            ParentIdDataSourceComboBoxQuery parentQ = new ParentIdDataSourceComboBoxQuery("a");
            KelAnggaranQuery kaQ = new KelAnggaranQuery("b");
            kaQ.Select(kaQ.KaId.As("KaId"), kaQ.KaCode.As("KaCode"), kaQ.KaName.As("KaName"), parentQ.KaName.As("Parent"), kaQ.GtCode.As("GtCode"), kaQ.Prefix.As("Prefix"), kaQ.KaLevel.As("KaLevel"), kaQ.Type.As("Type"), kaQ.IsDetail.As("IsDetail"), kaQ.IsActive.As("IsActive"), kaQ.IsKas.As("IsKas"));            
            kaQ.InnerJoin(parentQ).On(kaQ.ParentCode == parentQ.KaCode);
            kaColl.Load(kaQ);
            DataTable dtKA = kaQ.LoadDataTable();
            
            foreach (DataRow dr in dtKA.Rows)
            {
                for (int i = 0; i <= Convert.ToInt32(dr["KaLevel"]); i++)
                {
                    if (i != 0)
                    {
                        dr["KaName"] = "&nbsp;&nbsp;&nbsp;&nbsp;" + dr["KaName"];
                        dr.AcceptChanges();
                    }
                }
            }
            //this.RadGrid1.DataSource = kelAg;
            this.RadGrid1.DataSource = dtKA;
        }
Beispiel #2
0
 public bool Load(KelAnggaranQuery query)
 {
     this.query = query;
     base.InitQuery(this.query);
     return(this.Query.Load());
 }
Beispiel #3
0
        protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            string month = DateTime.Now.Month.ToString().Trim();
            string autonumber = "";
            if (month.Length == 1)
                month = ('0' + month).Trim();

            Trans Trans = new Trans();
            //Auto Number
            AutoNumberingQuery anQ = new AutoNumberingQuery();
            anQ.SelectAll();
            anQ.Where(anQ.KaMonth == month, anQ.KaYear == DateTime.Now.Year.ToString().Trim());
            AutoNumberingCollection anColl = new AutoNumberingCollection();

            anColl.Load(anQ);
            KelAnggaranQuery kaQ = new KelAnggaranQuery();
            kaQ.SelectAll();
            kaQ.Where(kaQ.KaCode == (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedValue.Trim());
            KelAnggaranCollection kaColl = new KelAnggaranCollection();

            kaColl.Load(kaQ);
            if (kaColl.Count > 0)
                foreach (KelAnggaran kkk in kaColl)
                    autonumber = kkk.Prefix.Trim();
            else
                return;

            if (anColl.Count == 0)
            {
                AutoNumbering an = new AutoNumbering { KaYear = DateTime.Now.Year.ToString().Trim(), KaMonth = month, LastNumber = 1, PrefixNumber = "000" };
                autonumber = String.Format("{0}{1}{2}-0001", autonumber, DateTime.Now.Year.ToString().Trim(), month);
                an.Save();
            }
            else
                foreach (AutoNumbering aa in anColl)
                {
                    string i = (aa.LastNumber + 1).ToString().Trim();
                    if (i.Length == 1)
                        autonumber = String.Format("{0}{1}{2}-000{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 2)
                        autonumber = String.Format("{0}{1}{2}-00{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 3)
                        autonumber = String.Format("{0}{1}{2}-0{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 4)
                        autonumber = String.Format("{0}{1}{2}-{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    AutoNumbering anb = new AutoNumbering();
                    if (anb.LoadByPrimaryKey((long)aa.Id))
                    {
                        anb.LastNumber = aa.LastNumber + 1;
                        anb.Save();
                    }
                }

            try
            {
                Trans.KaCode = (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedValue.ToUpper();
                Trans.TransNumber = autonumber.ToUpper();
                Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text.ToUpper();
                //Trans.Amount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value - (userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value);
                Trans.DebitAmount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value);
                Trans.CreditAmount = Convert.ToDecimal((userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value);
                Trans.Descript = (userControl.FindControl("txtDESC") as RadTextBox).Text.ToUpper();
                Trans.KasId = (userControl.FindControl("cmbKasID") as RadComboBox).SelectedValue.ToUpper();
                Trans.TransDate = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate;
                Trans.UserInsert = "toro";
                Trans.TglInsert = DateTime.Now;
                Trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"];
                Trans.Isverified = false;
                Trans.IsClosed = false;
                Trans.Save();
            }
            catch (Exception ex)
            {
                string es = ex.Message;
            }
            finally
            {
                RadGrid1.Rebind();
            }
        }
 private DataTable GetDataTableKA()
 {
     KelAnggaranQuery kaQ = new KelAnggaranQuery();
     kaQ.es2.Connection.Name = "LIVE";
     kaQ.Select(kaQ.KaCode, kaQ.KaName);
     kaQ.Where(kaQ.KaLevel == 3);
     dtKa = kaQ.LoadDataTable();            
     return dtKa;
 }