public void Proceed() { int lasnumber = 0; DateTime transdate = DateTime.Now; TransQuery trans = new TransQuery("a"); trans.SelectAll(); trans.Where(trans.TransNumber >= txtTransNumber.Text.Trim()); trans.OrderBy(trans.TransNumber.Ascending,trans.BkuId.Ascending); TransCollection tC = new TransCollection(); if (tC.Load(trans)) { string autonumber = "201212-0438"; int count = 438; foreach (Trans t in tC) { Trans tt = new Trans(); if (tt.LoadByPrimaryKey((long)t.BkuId)) { string number = count.ToString().Trim(); if (number.Length == 3) number = "0" + number; tt.TransNumber = "201212-" + number; tt.Save(); count++; } } } }
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 RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); DateTime TransDateMonth = DateTime.Now; try { TransDateMonth = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate; } catch (Exception ex) { string error = ex.Message; } int transDateMonth = TransDateMonth.Month; //perubahan terakhir, autonumber mengikuti bulan transaksi, bukan bulan berjalan //string month = DateTime.Now.Month.ToString().Trim(); string month = transDateMonth.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 (anColl.Count == 0) { AutoNumberingCollection anCollection = new AutoNumberingCollection(); AutoNumbering aN = new AutoNumbering(); aN = anCollection.AddNew(); aN.KaYear = DateTime.Now.Year.ToString().Trim(); aN.KaMonth = month; aN.LastNumber = 1; aN.PrefixNumber = "000"; //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(); try { TransCollection transCollection = new TransCollection(); Trans = transCollection.AddNew(); //Trans.KaCode = (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedItem.Value; Trans.KaCode = (userControl.FindControl("HiddenField1") as HiddenField).Value; Trans.TransNumber = autonumber.ToUpper(); Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text; //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; 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; using (esTransactionScope scope = new esTransactionScope()) { anCollection.Save(); transCollection.Save(); scope.Complete(); } } catch (Exception ex) { string es = ex.Message; } finally { RadGrid1.Rebind(); } } 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(); AutoNumberingCollection anCollection = new AutoNumberingCollection(); anb = anCollection.AddNew(); if (anb.LoadByPrimaryKey((long)aa.Id)) { anb.LastNumber = aa.LastNumber + 1; try { TransCollection transCollection = new TransCollection(); Trans = transCollection.AddNew(); Trans.KaCode = (userControl.FindControl("HiddenField1") as HiddenField).Value; Trans.TransNumber = autonumber.ToUpper(); Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text; 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; 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; anb.LastNumber = aa.LastNumber + 1; using (esTransactionScope scope = new esTransactionScope()) { transCollection.Save(); scope.Complete(); } anb.Save(); } catch (Exception ex) { string es = ex.Message; } finally { RadGrid1.Rebind(); } } } }
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); Trans Trans = new Trans(); if (Trans.LoadByPrimaryKey(Convert.ToInt32((userControl.FindControl("txtTransID") as RadTextBox).Text))) { try { Trans.KaCode = (userControl.FindControl("HiddenField1") as HiddenField).Value; Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text; 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; Trans.TransDate = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate; Trans.KasId = (userControl.FindControl("HiddenField2") as HiddenField).Value; Trans.UserUpdate = "toro"; Trans.TglUpdate = DateTime.Now; Trans.Isverified = false; Trans.IsClosed = false; Trans.Save(); } catch (Exception ex) { string es = ex.Message; } finally { RadGrid1.Rebind(); } } }
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.Now; Trans.UserInsert = "toro"; Trans.TglInsert = DateTime.Now; Trans.PeriodId = (long)HttpContext.Current.Session["_periodeId"]; Trans.Isverified = false; Trans.IsClosed = false; Trans.Save(); } catch (Exception ex) { string es = ex.Message; } finally { RadGrid1.Rebind(); } }
protected void cmdSave_Click(object sender, EventArgs e) { //ADD Trans trans = new Trans(); string Descript = txtDescription.Text; string CreditAmoun = txtCreditAmount.Text; if (Request.QueryString["BKU_ID"] == null) { int TransDateMonth = ((DateTime)dtpTransDate.SelectedDate).Month; string month = TransDateMonth.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); //New month, new autonumber if (anColl.Count == 0) { AutoNumberingCollection anCollection = new AutoNumberingCollection(); AutoNumbering aN = new AutoNumbering(); aN = anCollection.AddNew(); aN.KaYear = DateTime.Now.Year.ToString().Trim(); aN.KaMonth = month; aN.LastNumber = 1; aN.PrefixNumber = "000"; autonumber = String.Format("{0}{1}{2}-0001", autonumber, DateTime.Now.Year.ToString().Trim(), month); try { Decimal DebitAmount = 0; Decimal CreditAmount = 0; TransCollection transColl = new TransCollection(); trans = transColl.AddNew(); trans.TransNumber = autonumber.ToUpper(); trans.KaCode = cmbTransCode.SelectedValue; trans.TransDate = dtpTransDate.SelectedDate; trans.KasId = cmbKasID.SelectedValue; trans.Descript = txtDescription.Text; trans.CekBgNumber = txtCekBG.Text; if (Decimal.TryParse(txtDebitAmount.Text, out DebitAmount)) trans.DebitAmount = DebitAmount; else trans.DebitAmount = 0; if (Decimal.TryParse(txtCreditAmount.Text, out CreditAmount)) trans.CreditAmount = CreditAmount; else trans.CreditAmount = 0; trans.UserInsert = HttpContext.Current.Session["UserId"].ToString(); trans.TglInsert = DateTime.Now; trans.Isverified = false; trans.IsClosed = false; trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; using (esTransactionScope scope = new esTransactionScope()) { anCollection.Save(); transColl.Save(); scope.Complete(); } } catch (Exception ex) { string es = ex.Message; } } // If month already exist, increment autonumber 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(); AutoNumberingCollection anCollection = new AutoNumberingCollection(); anb = anCollection.AddNew(); if (anb.LoadByPrimaryKey((long)aa.Id)) { anb.LastNumber = aa.LastNumber + 1; try { Decimal DebitAmount = 0; Decimal CreditAmount = 0; TransCollection transColl = new TransCollection(); trans = transColl.AddNew(); trans.TransNumber = autonumber.ToUpper(); trans.KaCode = cmbTransCode.SelectedValue; trans.TransDate = dtpTransDate.SelectedDate; trans.KasId = cmbKasID.SelectedValue; trans.CekBgNumber = txtCekBG.Text; trans.KasId = cmbKasID.SelectedValue; trans.Descript = txtDescription.Text; if (Decimal.TryParse(txtDebitAmount.Text, out DebitAmount)) trans.DebitAmount = DebitAmount; else trans.DebitAmount = 0; if (Decimal.TryParse(txtCreditAmount.Text, out CreditAmount)) trans.CreditAmount = CreditAmount; else trans.CreditAmount = 0; trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; trans.Isverified = false; trans.IsClosed = false; trans.UserInsert = HttpContext.Current.Session["UserId"].ToString(); trans.TglInsert = DateTime.Now; anb.LastNumber = aa.LastNumber + 1; using (esTransactionScope scope = new esTransactionScope()) { transColl.Save(); anb.Save(); scope.Complete(); } //anb.Save(); } catch (Exception ex) { string es = ex.Message; } } } } } //EDIT else { long bkuID = 0; Decimal DebitAmount = 0; Decimal CreditAmount = 0; try { if (long.TryParse(txtTransID.Text, out bkuID)) { if (trans.LoadByPrimaryKey(bkuID)) { trans.TransDate = dtpTransDate.SelectedDate; trans.KaCode = cmbTransCode.SelectedItem.Value; trans.KasId = cmbKasID.SelectedItem.Value; trans.Descript = Descript; trans.CekBgNumber = txtCekBG.Text; if (Decimal.TryParse(txtDebitAmount.Text, out DebitAmount)) trans.DebitAmount = DebitAmount; else trans.DebitAmount = 0; if (Decimal.TryParse(txtCreditAmount.Text, out CreditAmount)) trans.CreditAmount = CreditAmount; else trans.CreditAmount = 0; trans.UserUpdate = HttpContext.Current.Session["UserId"].ToString(); trans.TglUpdate = DateTime.Now; trans.Save(); } } } catch (Exception ex) { string es = ex.Message; } } if (Request.QueryString["BKU_ID"] != null) { ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind('navigateAndRebind');", true); HttpContext.Current.Session["CUDMode"] = "1"; // EDIT } else { ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true); HttpContext.Current.Session["CUDMode"] = "0"; //ADD } }
public void SaveData() { //Validasi if (string.IsNullOrEmpty(txtTransInvoiceNo.Text) || string.IsNullOrEmpty(cmbTransKa.SelectedItem.Value) || string.IsNullOrEmpty(txtTransInvoiceNote.Text) || string.IsNullOrEmpty(dfTransInvoiceDate.SelectedDate.ToShortDateString()) || string.IsNullOrEmpty(cmbTransKasId.SelectedItem.Value)) { X.Msg.Alert("Error on Transaction Tab", "Please fill neccessary field").Show(); return; } if (string.IsNullOrEmpty(txtPpnInvoiceNo.Text) || string.IsNullOrEmpty(cmbPPnKa.SelectedItem.Value) || string.IsNullOrEmpty(txtPPnInvoiceNote.Text) || string.IsNullOrEmpty(dfPPnInvoiceDate.SelectedDate.ToShortDateString()) || string.IsNullOrEmpty(cmbPPnKas.SelectedItem.Value)) { X.Msg.Alert("Error on PPN Tab", "Please fill neccessary field").Show(); return; } if (string.IsNullOrEmpty(txtPphInvoiceNo.Text) || string.IsNullOrEmpty(cmbPPhKa.SelectedItem.Value) || string.IsNullOrEmpty(txtPPhInvoiceNote.Text) || string.IsNullOrEmpty(dfPPhInvoiceDate.SelectedDate.ToShortDateString()) || string.IsNullOrEmpty(cmbPPhKas.SelectedItem.Value)) { X.Msg.Alert("Error on PPh Tab", "Please fill neccessary field").Show(); return; } // Save Transaksi ke Tabel Trans RSCM_BKU int transMonth = dfTransInvoiceDate.SelectedDate.Month; string month = transMonth.ToString().Trim(); if (month.Length == 1) month = "0" + month; string year = dfTransInvoiceDate.SelectedDate.Year.ToString().Trim(); string autonumber = string.Empty; Trans Trans = new Trans(); Trans.es.Connection.Name = "LIVE"; //Auto Number AutoNumberingQuery anQ = new AutoNumberingQuery(); anQ.es2.Connection.Name = "LIVE"; anQ.SelectAll(); anQ.Where(anQ.KaMonth == month, anQ.KaYear == year); AutoNumberingCollection anColl = new AutoNumberingCollection(); anColl.Load(anQ); decimal DebitAmount = 0; decimal CreditAmount = 0; if (anColl.Count == 0) { AutoNumbering aN = new AutoNumbering(); aN.es.Connection.Name = "LIVE"; aN.KaYear = DateTime.Now.Year.ToString().Trim(); aN.KaMonth = month; aN.LastNumber = 3; aN.PrefixNumber = "000"; //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(); string autonumberPpn = String.Format("{0}{1}{2}-0002", string.Empty, DateTime.Now.Year.ToString().Trim(), month); string autonumberPph = String.Format("{0}{1}{2}-0003", string.Empty, DateTime.Now.Year.ToString().Trim(), month); aN.Save(); try { //Transaksi Trans.KaCode = cmbTransKa.SelectedItem.Value; Trans.TransNumber = autonumber.ToUpper(); Trans.CekBgNumber = txtTransBG.Text; if (string.IsNullOrEmpty(txtTransDebitAmount.Text.Trim())) DebitAmount = 0; else { if (!decimal.TryParse(txtTransDebitAmount.Text.Trim(),out DebitAmount)) DebitAmount = 0; } if (string.IsNullOrEmpty(txtTransCreditAmount.Text.Trim())) CreditAmount = 0; else { if (!decimal.TryParse(txtTransCreditAmount.Text.Trim(), out CreditAmount)) CreditAmount = 0; } Trans.DebitAmount = DebitAmount; Trans.CreditAmount = CreditAmount; Trans.Descript = txtTransInvoiceNo.Text + " - " + txtTransInvoiceNote.Text; Trans.KasId = cmbTransKasId.SelectedItem.Value; Trans.TransDate = dfTransInvoiceDate.SelectedDate; Trans.UserInsert = (string)HttpContext.Current.Session["UserId"]; Trans.TglInsert = DateTime.Now; Trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; //Trans.PeriodId = 1; Trans.Isverified = false; Trans.IsClosed = false; Trans.Save(); //PPn Trans TransPpn = new Trans(); TransPpn.es.Connection.Name = "LIVE"; TransPpn.KaCode = cmbPPnKa.SelectedItem.Value; TransPpn.TransNumber = autonumberPpn.ToUpper(); TransPpn.CekBgNumber = txtPPnBG.Text; if (string.IsNullOrEmpty(txtPPnDebitAmount.Text.Trim())) DebitAmount = 0; else { if (!decimal.TryParse(txtPPnDebitAmount.Text.Trim(), out DebitAmount)) DebitAmount = 0; } if (string.IsNullOrEmpty(txtPPnCreditAmount.Text.Trim())) CreditAmount = 0; else { if (!decimal.TryParse(txtPPnCreditAmount.Text.Trim(), out CreditAmount)) CreditAmount = 0; } TransPpn.DebitAmount = DebitAmount; TransPpn.CreditAmount = CreditAmount; TransPpn.Descript = "Terima PPN dari " + txtPPnSupplierName.Text; TransPpn.KasId = cmbPPnKas.SelectedItem.Value; TransPpn.TransDate = dfPPnInvoiceDate.SelectedDate; TransPpn.UserInsert = (string)HttpContext.Current.Session["UserId"]; TransPpn.TglInsert = DateTime.Now; TransPpn.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; //TransPpn.PeriodId = 1; TransPpn.Isverified = false; TransPpn.IsClosed = false; TransPpn.Save(); //PPh Trans TransPph = new Trans(); TransPph.es.Connection.Name = "LIVE"; TransPph.KaCode = cmbPPhKa.SelectedItem.Value; TransPph.TransNumber = autonumberPph.ToUpper(); TransPph.CekBgNumber = txtPPhBG.Text; if (string.IsNullOrEmpty(txtPPhDebitAmount.Text.Trim())) DebitAmount = 0; else { if (!decimal.TryParse(txtPPhDebitAmount.Text.Trim(), out DebitAmount)) DebitAmount = 0; } if (string.IsNullOrEmpty(txtPPhCreditAmount.Text.Trim())) CreditAmount = 0; else { if (!decimal.TryParse(txtPPhCreditAmount.Text.Trim(), out CreditAmount)) CreditAmount = 0; } TransPph.DebitAmount = DebitAmount; TransPph.CreditAmount = CreditAmount; if (chkPPh22.Checked) TransPph.Descript = "Terima PPh 22 dari " + txtPPhSupplierName.Text; else TransPph.Descript = "Terima PPh 23 dari " + txtPPhSupplierName.Text; TransPph.KasId = cmbPPhKas.SelectedItem.Value; TransPph.TransDate = dfPPhInvoiceDate.SelectedDate; TransPph.UserInsert = (string)HttpContext.Current.Session["UserId"]; TransPph.TglInsert = DateTime.Now; TransPph.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; //TransPph.PeriodId = 1; TransPph.Isverified = false; TransPph.IsClosed = false; TransPph.Save(); } catch (Exception ex) { X.Msg.Alert("Error", ex.Message).Show(); } } 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); string j = (aa.LastNumber + 2).ToString().Trim(); string autonumberPPn = string.Empty; if (j.Length == 1) autonumberPPn = String.Format("{0}{1}{2}-000{3}", autonumberPPn, aa.KaYear, aa.KaMonth, j); if (j.Length == 2) autonumberPPn = String.Format("{0}{1}{2}-00{3}", autonumberPPn, aa.KaYear, aa.KaMonth, j); if (j.Length == 3) autonumberPPn = String.Format("{0}{1}{2}-0{3}", autonumberPPn, aa.KaYear, aa.KaMonth, j); if (j.Length == 4) autonumberPPn = String.Format("{0}{1}{2}-{3}", autonumberPPn, aa.KaYear, aa.KaMonth, j); string k = (aa.LastNumber + 3).ToString().Trim(); string autonumberPPh = string.Empty; if (k.Length == 1) autonumberPPh = String.Format("{0}{1}{2}-000{3}", autonumberPPh, aa.KaYear, aa.KaMonth, k); if (k.Length == 2) autonumberPPh = String.Format("{0}{1}{2}-00{3}", autonumberPPh, aa.KaYear, aa.KaMonth, k); if (k.Length == 3) autonumberPPh = String.Format("{0}{1}{2}-0{3}", autonumberPPh, aa.KaYear, aa.KaMonth, k); if (k.Length == 4) autonumberPPh = String.Format("{0}{1}{2}-{3}", autonumberPPh, aa.KaYear, aa.KaMonth, k); AutoNumbering anb = new AutoNumbering(); anb.es.Connection.Name = "LIVE"; if (anb.LoadByPrimaryKey((long)aa.Id)) { anb.LastNumber = aa.LastNumber + 3; try { //Transaksi Trans.KaCode = cmbTransKa.SelectedItem.Value; Trans.TransNumber = autonumber.ToUpper(); Trans.CekBgNumber = txtTransBG.Text; if (string.IsNullOrEmpty(txtTransDebitAmount.Text.Trim())) DebitAmount = 0; else { if (!decimal.TryParse(txtTransDebitAmount.Text.Trim(), out DebitAmount)) DebitAmount = 0; } if (string.IsNullOrEmpty(txtTransCreditAmount.Text.Trim())) CreditAmount = 0; else { if (!decimal.TryParse(txtTransCreditAmount.Text.Trim(), out CreditAmount)) CreditAmount = 0; } Trans.DebitAmount = DebitAmount; Trans.CreditAmount = CreditAmount; Trans.Descript = txtTransInvoiceNo.Text + " - " + txtTransInvoiceNote.Text; Trans.KasId = cmbTransKasId.SelectedItem.Value; Trans.TransDate = dfTransInvoiceDate.SelectedDate; Trans.UserInsert = (string)HttpContext.Current.Session["UserId"]; Trans.TglInsert = DateTime.Now; Trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; //Trans.PeriodId = 1; Trans.Isverified = false; Trans.IsClosed = false; Trans.Save(); //PPn Trans TransPpn = new BusinessObjects.Trans(); TransPpn.es.Connection.Name = "LIVE"; TransPpn.KaCode = cmbPPnKa.SelectedItem.Value; TransPpn.TransNumber = autonumberPPn.ToUpper(); TransPpn.CekBgNumber = txtPPnBG.Text; if (string.IsNullOrEmpty(txtPPnDebitAmount.Text.Trim())) DebitAmount = 0; else { if (!decimal.TryParse(txtPPnDebitAmount.Text.Trim(), out DebitAmount)) DebitAmount = 0; } if (string.IsNullOrEmpty(txtPPnCreditAmount.Text.Trim())) CreditAmount = 0; else { if (!decimal.TryParse(txtPPnCreditAmount.Text.Trim(), out CreditAmount)) CreditAmount = 0; } TransPpn.DebitAmount = DebitAmount; TransPpn.CreditAmount = CreditAmount; TransPpn.Descript = "Terima PPN dari " + txtPPnSupplierName.Text; TransPpn.KasId = cmbPPnKas.SelectedItem.Value; TransPpn.TransDate = dfPPnInvoiceDate.SelectedDate; TransPpn.UserInsert = (string)HttpContext.Current.Session["UserId"]; TransPpn.TglInsert = DateTime.Now; TransPpn.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; //TransPpn.PeriodId = 1; TransPpn.Isverified = false; TransPpn.IsClosed = false; TransPpn.Save(); //PPh BusinessObjects.Trans TransPPh = new BusinessObjects.Trans(); TransPPh.es.Connection.Name = "LIVE"; TransPPh.KaCode = cmbPPhKa.SelectedItem.Value; TransPPh.TransNumber = autonumberPPh.ToUpper(); TransPPh.CekBgNumber = txtPPhBG.Text; if (string.IsNullOrEmpty(txtPPhDebitAmount.Text.Trim())) DebitAmount = 0; else { if (!decimal.TryParse(txtPPhDebitAmount.Text.Trim(), out DebitAmount)) DebitAmount = 0; } if (string.IsNullOrEmpty(txtPPhCreditAmount.Text.Trim())) CreditAmount = 0; else { if (!decimal.TryParse(txtPPhCreditAmount.Text.Trim(), out CreditAmount)) CreditAmount = 0; } TransPPh.DebitAmount = DebitAmount; TransPPh.CreditAmount = CreditAmount; if (chkPPh22.Checked) TransPPh.Descript = "Terima PPh 22 dari " + txtPPhSupplierName.Text; else TransPPh.Descript = "Terima PPh 23 dari " + txtPPhSupplierName.Text; TransPPh.KasId = cmbPPnKas.SelectedItem.Value; TransPPh.TransDate = dfPPnInvoiceDate.SelectedDate; TransPPh.UserInsert = (string)HttpContext.Current.Session["UserId"]; TransPPh.TglInsert = DateTime.Now; TransPPh.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; //TransPPh.PeriodId = 1; TransPPh.Isverified = false; TransPPh.IsClosed = false; TransPPh.Save(); anb.LastNumber = aa.LastNumber + 3; anb.Save(); } catch (Exception ex) { X.Msg.Alert("Error", ex.Message).Show(); } } } //Save PPn ke Tabel Trans RSCM_BKU InvoiceSupplier inSu = new InvoiceSupplier(); inSu.es.Connection.Name = "KENCANA"; if (inSu.LoadByPrimaryKey(invoiceNo)) { inSu.Isproces = true; inSu.Save(); } HttpContext.Current.Session["isProcess"] = true; X.AddScript("parentAutoLoadControl.close();"); }