protected void Page_Load(object sender, EventArgs e) { SpacePartsList spacePartList = new SpacePartsList(); if (!IsPostBack) { Panel1.Visible = false; Panel_Report_View.Visible = false; Panel_Report.Visible = false; } }
public void bindDataStock(DataTable dt) { round = Convert.ToInt32(Session["Round"]); Date_Count_Stock = Convert.ToDateTime(Session["Date_Count_Stock"]); ID_Brach = Convert.ToInt32(Session["ID_Brach"]); SpacePartsList space_part_list = new SpacePartsList(); dataStock.DataSource = space_part_list.getData(Date_Count_Stock.Date, ID_Brach, round); //dataStock.DataSource = dt; dataStock.DataBind(); }
public void uploadToDatabase() { SpacePartsList spacePartList = new SpacePartsList(); String id_item; String name_item; String group_item; double sell_price_unit; double sell_price_all; double cost_price_unit; double cost_price_all; String shelf_main; String shelf_try; String date_count_stock; //int round; double total_stock; double amound_sold; double number_part_booking; double invertory_last_month; int id_brach; dt = new DataTable(); try { string strFileName = FileUpload1.FileName; string path = Path.GetFileName(strFileName); path = path.Replace(" ", ""); FileUpload1.SaveAs(Server.MapPath("~/ExcelFile/") + path); String ExcelPath = Server.MapPath("~/ExcelFile/") + path; OleDbConnection mycon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelPath + ";Extended Properties='Excel 12.0 Xml;HDR=NO;'"); mycon.Open(); OleDbDataAdapter da = new OleDbDataAdapter("select * from [PartsInventoryReport_th$]", mycon); da.Fill(dt); //this.bindDataStock(dt); try { this.process_data(); foreach (DataRow item in dt.Rows) { // Response.Write("<br/>"+dr[0].ToString()); id_item = item[5].ToString(); name_item = item[6].ToString(); group_item = item[7].ToString(); sell_price_unit = double.MinValue; double.TryParse(item[22].ToString(), out sell_price_unit); sell_price_all = double.MinValue; double.TryParse(item[23].ToString(), out sell_price_all); cost_price_unit = double.MinValue; double.TryParse(item[24].ToString(), out cost_price_unit); cost_price_all = double.MinValue; double.TryParse(item[25].ToString(), out cost_price_all); shelf_main = item[3].ToString() == "" ? null : item[3].ToString(); shelf_try = item[4].ToString() == "" ? null : item[4].ToString(); date_count_stock = DateStock.Text.ToString(); //date_count_stock = DateTime.Now; //round = Convert.ToInt32(CountRound.Value.ToString()); //round = 1; total_stock = double.MinValue; double.TryParse(item[12].ToString(), out total_stock); amound_sold = double.MinValue; double.TryParse(item[13].ToString(), out amound_sold); number_part_booking = double.MinValue; double.TryParse(item[19].ToString(), out number_part_booking); invertory_last_month = double.MinValue; double.TryParse(item[11].ToString(), out invertory_last_month); id_brach = Convert.ToInt32(Select_Brach.Value.ToString()); spacePartList.savedata(id_item, name_item, group_item, sell_price_unit, sell_price_all, cost_price_unit, cost_price_all, shelf_main, shelf_try, date_count_stock, total_stock, amound_sold, number_part_booking, invertory_last_month, id_brach); } } catch { title_upload.Text = "Upload Error "; title_upload.ForeColor = System.Drawing.Color.Orange; } finally { title_upload.Text = "เพิ่มข้อมูล Excel เรียบร้อย"; title_upload.ForeColor = System.Drawing.Color.Green; } } catch (Exception ex) { title_upload.Text = ex.Message; title_upload.ForeColor = System.Drawing.Color.Red; } }