Ejemplo n.º 1
0
    protected bool SaveToDB(string path, string tablename)
    {
        try
        {
            DataTable dt = ExcelManage.InputFromExcel(path, tablename);
            if (dt != null && dt.Rows.Count > 0)
            {
                WsSystem wbi = new WsSystem();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (!string.IsNullOrEmpty(dt.Rows[i][0].ToString()))
                    {
                        BasMateriel bb = new BasMateriel();
                        bb.QPARTNO  = dt.Rows[i][0].ToString();
                        bb.CPARTNO  = dt.Rows[i][1].ToString();
                        bb.NAME     = dt.Rows[i][2].ToString();
                        bb.BasQty   = Convert.ToInt32(dt.Rows[i][3].ToString());
                        bb.CUSTOMER = dt.Rows[i][4].ToString();
                        bb.MEMO     = dt.Rows[i][5].ToString();

                        wbi.SaveMaterielInfo(bb);
                    }
                }
                return(true);
            }
            else
            {
                Label1.Text = "上传完毕,但数据为空,保存失败";
            }
            return(true);
        }
        catch (Exception ex)
        {
            Label1.Text = ex.ToString();
            return(false);
        }
    }