private void GenerateVouchers() { decimal Total = VSDetailList.Sum(x => x.Quantity); string Status = "{0} of " + Total.ToString() + " Done"; Dispatcher d = Dispatcher.CurrentDispatcher; ThreadPool.QueueUserWorkItem(x => { using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString)) { conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { foreach (TParkingSalesDetails pSD in _VSDetailList) { VoucherType vt = VTypeList.First(y => y.VoucherId == pSD.ProdId && y.SkipVoucherGeneration == false); for (int i = 1; i <= pSD.Quantity; i++) { Voucher v = new Voucher() { BillNo = pSD.BillNo, ExpDate = CurDate.AddDays(vt.Validity), ValidStart = vt.ValidStart, ValidEnd = vt.ValidEnd, VoucherName = vt.VoucherName, Value = vt.Value, Sno = i, VoucherId = vt.VoucherId, FYID = GlobalClass.FYID }; do { v.Barcode = "#" + new Random().Next(1677215).ToString("X"); }while (tran.Connection.ExecuteScalar <int>("SELECT COUNT(*) FROM ParkingVouchers WHERE Barcode = @Barcode", v, transaction: tran) > 0); v.Save(tran); ParkingVouchers.Add(v); d.BeginInvoke((Action)(() => { GenCount = string.Format(Status, ParkingVouchers.Count); Progress = ParkingVouchers.Count / Total * 100; })); } } tran.Commit(); PrintVouchers(_VSDetailList.First().BillNo, true, d); } } }); }
private void ResizeGrid() { var columns = SliderGrid.ColumnDefinitions.ToList(); var i = (int)SliderCalc.Value; foreach (var column in columns) { column.Width = new GridLength(1, GridUnitType.Star); } columns[i].Width = GridLength.Auto; CurDate.SetValue(Grid.ColumnProperty, i); SlideEarn.SetValue(Grid.ColumnProperty, i); }
public override void DataBind() { string[] users = Users.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (ShowUsers) { DataTable userTable = new DataTable(); userTable.Locale = CultureInfo.InvariantCulture; userTable.Columns.Add(new DataColumn("UserId", typeof(int))); userTable.Columns.Add(new DataColumn("Details", typeof(string))); foreach (string s in users) { int userId = int.Parse(s, CultureInfo.InvariantCulture); string details = String.Empty; if (!Mediachase.IBN.Business.Calendar.CheckUserCalendar(userId)) { details = LocRM.GetString("NoCalendar"); } DataRow dr = userTable.NewRow(); dr["UserId"] = userId; dr["Details"] = details; userTable.Rows.Add(dr); } UsersGrid.DataSource = userTable.DefaultView; UsersGrid.DataBind(); } ImageHeight = users.Length * ResourceChart.ItemHeight; // +ResourceChart.HeaderHeight; divImg.Style.Add(HtmlTextWriterStyle.Height, (ImageHeight + ResourceChart.HeaderHeight).ToString() + "px"); LinkToGraph.Value = String.Format(CultureInfo.InvariantCulture, "{0}?Users={1}&Vast={2}&StartDate={3}&CurDate={4}&ObjectTypes={5}&HObjects={6}&HTypes={7}", ResolveClientUrl("~/Projects/ResourceChartImage.aspx"), Users, IntervalDuration == 7, StartDate.ToString("yyyy-MM-dd"), Server.UrlEncode(CurDate.ToString("yyyy-MM-dd HH:mm")), ObjectTypes, HObjects, HTypes); base.DataBind(); }
private async Task GenerateVouchers(SqlTransaction tran) { decimal Total = VSDetailList.Sum(x => x.Quantity); string Status = "{0} of " + Total.ToString() + " Done"; await Task.Run(() => { foreach (TParkingSalesDetails pSD in _VSDetailList) { VoucherType vt = VTypeList.FirstOrDefault(y => y.VoucherId == pSD.ProdId && y.SkipVoucherGeneration == false); if (vt != null) { for (int i = 1; i <= pSD.Quantity; i++) { Voucher v = new Voucher() { BillNo = pSD.BillNo, ExpDate = CurDate.AddDays(vt.Validity), ValidStart = vt.ValidStart, ValidEnd = vt.ValidEnd, VoucherName = vt.VoucherName, Value = vt.Value, Sno = i, VoucherId = vt.VoucherId, FYID = GlobalClass.FYID }; do { v.Barcode = "#" + new Random().Next(1677215).ToString("X"); }while (tran.Connection.ExecuteScalar <int>("SELECT COUNT(*) FROM ParkingVouchers WHERE Barcode = @Barcode", v, transaction: tran) > 0); v.Save(tran); ParkingVouchers.Add(v); GenCount = string.Format(Status, ParkingVouchers.Count); Progress = ParkingVouchers.Count / Total * 100; } } } }); }
protected void NextMonth_Btn_Click(object sender, EventArgs e) { CurDate = CurDate.AddMonths(1); MyBind(); }
public override string ToString() { return(CurDate.ToString()); }