//private void multipleDeleteButton_Click(object sender, EventArgs e) //{ // DateTime time1 = Convert.ToDateTime(clearDatePicker.Text); // if (MessageBox.Show("The Log before " + time1.Date + " will be deleted", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.Yes) // using (ItemContext ctx = new ItemContext()) // { // var list = ctx.ItemOutbounds.Where(a=>a.isDelete == false).Where(a => a.Date.CompareTo(time1) < 0); // foreach (var it in list) // { // it.isDelete = true; // ctx.ItemOutbounds.Attach(it); // ctx.Entry(it).Property(x => x.isDelete).IsModified = true; // }; // ctx.SaveChanges(); // MessageBox.Show("Clearance Successfully!"); // } // OutboundManagement_Load(this, e); //} private void SaveToLocal_Click(object sender, EventArgs e) { using (ItemContext ctx = new ItemContext()) { try { var ib = ctx.ItemOutbounds.Where(available => available.isDelete == false).Select(x => new { x.TrackingNum, x.ItemTitle, x.SN, x.Date, x.Manipulator, x.Qty }).ToList(); DataTable dt = ToDataSet(ib); ExcelTool et = new ExcelTool(); if (!et.initSavePath()) { return; } else { MessageBox.Show(et.writeToExcel(dt)); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void Save_Click(object sender, EventArgs e) { //OpenFileDialog path = new OpenFileDialog(); //path.Title = "Please Choose a Path:"; //path.Filter = "Excel Document(*.xls)|*.xls"; //path.Multiselect = false; //FolderBrowserDialog path = new FolderBrowserDialog(); //path.Description = "Pleas Choose a Path:"; //string file; DateTime time1 = Convert.ToDateTime(dateTimePicker1.Text); //if (path.ShowDialog() == DialogResult.OK) //{ // //file = path.SafeFileName; // file = path.SelectedPath; //} //else //{ // return; //} using (ItemContext ctx = new ItemContext()) { try { var ib = ctx.ItemBaks.Select(x => new { x.ItemTitle, x.SN, x.DateOfRcv, x.DateOfOut, x.UPC, x.OriginalTrackingNum, x.OrderId, x.Note, x.Condition, x.Listed, x.ReturnCode, x.OutTrackingNumber, x.ItemOutOperator }) .Where(a => a.DateOfOut.CompareTo(time1) < 0).ToList(); DataTable dt = ToDataSet(ib); ExcelTool et = new ExcelTool(); if (!et.initSavePath()) { return; } else { MessageBox.Show(et.writeToExcel(dt)); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }