Exemple #1
0
    /// <summary>
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void uploadClick(object sender, System.EventArgs e)
     {
         string path = string.Empty;
         string errorMsg = "";
         bool fileOK = false;
         string strfile = "";
         string strfileTemp = "";
         string fullName = "";
         try
         {
             if (this.txtBrowse.HasFile)
             {

                 strfile = this.txtBrowse.FileName;

                 String fileExtension =
                         System.IO.Path.GetExtension(strfile).ToLower();
                 String[] allowedExtensions = { ".xls", ".xlsx" };

                 for (int i = 0; i < allowedExtensions.Length; i++)
                 {
                     if (fileExtension.ToLower() == allowedExtensions[i].ToLower())
                     {
                         fileOK = true;
                         break;
                     }
                 }

                 if (!fileOK)
                 {
                     errorMsg = msgInvalidFileType;
                     writeToAlertMessage(errorMsg);
                 }
                 else
                 {
                     strfileTemp = DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() ;
                     fullName = Server.MapPath("../") + strfileTemp + strfile;
                     this.txtBrowse.PostedFile.SaveAs(fullName);
                 }
             }
             else
             {
                 showErrorMessage(msgEmptyFile);
             }
         }
         catch (FisException fe)
         {
             showErrorMessage(fe.mErrmsg);
             return;
         }
         catch (Exception ee)
         {
             showErrorMessage(ee.Message);
             return;
         }
         try
         {
             if (hidFileName.Value != "")
             {
                 iCOAReturn.Cancel(hidFileName.Value);
             }
             hidFileName.Value = strfileTemp;
             hidName.Value = strfile;
             TableClear();
             bool empty = true;
             S_COAReturn retTable = new S_COAReturn();
             DataTable dt = ExcelManager.getExcelSheetData(fullName);
             int i = 0;
             string SN = "";
             List<string> ret = new List<string>();
             foreach (DataRow dr in dt.Rows)
             {
                 i++;
                 if (i == 1)
                 {
                     continue;
                 }
                 else
                 {
                     SN = dr[0].ToString();
                     if (SN.Trim() == "")
                     {
                         break;
                     }
                     else
                     {
                         ret.Add(SN);
                     }
                 }
             }
             if (ret.Count > 0)
             {
                 retTable = iCOAReturn.GetProductTable("", UserId, station, Customer, hidFileName.Value, ret, true);
                 empty = false;
             }
             if (empty == true)
             {
                 showErrorMessage(msgFileEmpty);
                 return;
             }
             if (retTable.reValue == "true")
             {
                 if (retTable.validProduct.Count > 0)
                 {
                     DataTable dtV = initTableV();
                     DataRow newRow;

                     int cnt = 0;

                     foreach (S_RowData_COAReturn ele in retTable.validProduct)
                     {
                         newRow = dtV.NewRow();
                         newRow["SN"] += ele.SN;
                         newRow["COA"] += ele.COAorError;
                         dtV.Rows.Add(newRow);
                         cnt++;
                     }

                     for (; cnt < fullRowCount; cnt++)
                     {
                         newRow = dtV.NewRow();
                         dtV.Rows.Add(newRow);
                     }

                     this.gridviewV.DataSource = dtV;
                     this.gridviewV.DataBind();
                     updatePanelV.Update();
                     initTableColumnHeaderV();
                 }
                 if (retTable.inValidProduct.Count > 0)
                 {
                     DataTable dtE = initTableE();
                     DataRow newRow;
                     int cnt = 0;
                     foreach (S_RowData_COAReturn ele in retTable.inValidProduct)
                     {
                         newRow = dtE.NewRow();
                         newRow["SN"] += ele.SN;
                         newRow["ERROR"] += ele.COAorError;
                         dtE.Rows.Add(newRow);
                         cnt++;
                     }

                     for (; cnt < fullRowCount; cnt++)
                     {
                         newRow = dtE.NewRow();
                         dtE.Rows.Add(newRow);
                     }

                     this.gridviewE.DataSource = dtE;
                     this.gridviewE.DataBind();
                     updatePanelE.Update();
                     initTableColumnHeaderE();
                 }
             }

         }
         catch (FisException ee)
         {
             showErrorMessage(ee.mErrmsg);
             return;
         }
         catch (Exception ex)
         {
             if (ex.Message.IndexOf("Cannot find table 0") >= 0)
             {
                 showErrorMessage(msgFileEmpty);
             }
             else
             {
                 showErrorMessage(ex.Message);
             }
             return;
         }
         finally
         {
             deleteFiles(fullName);
         }
         writeToSuccessMessage(strfile);
     }
Exemple #2
0
 /// <summary>
 /// Get Product Table
 /// </summary>
 /// <param name="line">line</param>
 /// <param name="editor">editor</param>
 /// <param name="station">station</param>
 /// <param name="customer">customer</param>
 /// <param name="key">key</param>
 /// <param name="SN">SN</param> 
 /// <param name="complete">complete</param>  
 public S_COAReturn GetProductTable(string line, string editor, string station, string customer, string key, List<string> SN, bool complete)
 {
     string keyStr = "";
     try
     {
         bool first = false ;
         S_COAReturn ret = new S_COAReturn();
         ret.reValue = "false";
         string sessionKey = key;
         keyStr = sessionKey;
         List<string> validTemp = new List<string>() ;
         Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
         if (null == currentSession)
         {
             first = true;
             currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);
             currentSession.AddValue("SNListForCOAReturn", validTemp);
         }
         validTemp = (List<string>)currentSession.GetValue("SNListForCOAReturn");
         
         foreach (string tmp in SN)
         {
             if (validTemp.Contains(tmp))
             {
             }
             else
             {
                 validTemp.Add(tmp);
             }
         }
         currentSession.AddValue("SNListForCOAReturn", validTemp);
         
         validTemp = (List<string>)currentSession.GetValue("SNListForCOAReturn");
         List<S_RowData_COAReturn> inValidProduct = new List<S_RowData_COAReturn>();
         List<S_RowData_COAReturn> validProduct = new List<S_RowData_COAReturn>();
         foreach (string tmp in validTemp)
         {
             S_RowData_COAReturn aRow = new S_RowData_COAReturn();
             aRow.SN = tmp;
             aRow.COAorError = "";
             IProduct temp = productRepository.GetProductByCustomSn(tmp);
             if (null != temp)
             {
                 // IMES_FA..Product_Part 表中与当前Product 绑定的Parts 
                 IList<IProductPart> productParts = new List<IProductPart>();
                 productParts = temp.ProductParts;
                 /*if (productParts == null || productParts.Count <= 0)
                 {
                     aRow.COAorError = "未结合COA / OOA";
                     inValidProduct.Add(aRow);
                     continue;
                 }*/
                 COAReturnInfo cond = new COAReturnInfo();
                 cond.custsn = tmp;
                 COAReturnInfo empty = new COAReturnInfo();
                 empty.status = "";
                 IList<COAReturnInfo> reCOAReturnInfo =  coaRepository.GetCOAReturnInfoList(cond, empty);
                 if (null != reCOAReturnInfo && reCOAReturnInfo.Count > 0)
                 {
                    aRow.COAorError = "已经完成本站!";
                    inValidProduct.Add(aRow);
                    continue;
                 }
                 foreach (ProductPart iprodpart in productParts)
                 {
                     IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                     if (curPart.BOMNodeType == "P1" && curPart.Descr.IndexOf("COA") == 0)
                     {
                         COAStatus reCOA = coaRepository.Find(iprodpart.PartSn);
                         if (null == reCOA)
                         {
                             aRow.COAorError = "不存在COA";
                             inValidProduct.Add(aRow);
                         }
                         else
                         {
                             aRow.COAorError = iprodpart.PartSn;
                             validProduct.Add(aRow);
                         }
                         break;
                     }
                 }
                 string[] pizzIds;
                 pizzIds = new string[] { temp.PizzaID };
                 IList<string> partsn = repPizza.GetPartNoListFromPizzaPart(pizzIds, "P1", "DESC", "OOA");
                 foreach (string aPartSn in partsn)
                 {
                     COAStatus reCOA = coaRepository.Find(aPartSn);
                     if (null == reCOA)
                     {
                         aRow.COAorError = "不存在OOA";
                         inValidProduct.Add(aRow);
                     }
                     else
                     {
                         aRow.COAorError = aPartSn;
                         aRow.OOA = "true";
                         validProduct.Add(aRow);
                     }
                     break;
                 }
                 if (aRow.COAorError == "")
                 {
                     aRow.COAorError = "未结合COA / OOA";
                     inValidProduct.Add(aRow);
                 }
                 continue;
             }
             else
             {
                 aRow.COAorError = "Invalid Customer S/N!";
                 inValidProduct.Add(aRow);
                 continue;
             }
         }
         ret.reValue = "true";
         ret.validProduct = validProduct;
         ret.inValidProduct = inValidProduct;
         currentSession.AddValue("ValidProduct", validProduct);
         if (first == true && inValidProduct.Count == 0)
         {
             SessionManager.GetInstance.AddSession(currentSession);
         }
         return ret;
     }
     catch (FisException e)
     {
         logger.Error(e.mErrmsg, e);
         throw new Exception(e.mErrmsg);
     }
     catch (Exception ee)
     {
         throw ee;
     }
 }
Exemple #3
0
    public void btnGetProductTable_ServerClick(object sender, System.EventArgs e)
    {
        try
        {
            TableClear();
            iCOAReturn.Cancel(hidFileName.Value);
            S_COAReturn retTable = new S_COAReturn();
            DataTable dt = ExcelManager.getExcelSheetData(hidFileName.Value);
            int i = 0;
            string SN = "";
            List<string> ret = new List<string>();
            foreach (DataRow dr in dt.Rows)
            {
                i++;
                if (i == 1)
                {
                    continue;
                }
                else
                {
                    SN = dr[0].ToString();
                    if (SN.Trim() == "")
                    {
                        continue;
                    }
                    else
                    {
                        ret.Add(SN);
                        if (ret.Count == 100)
                        {
                            if (i == dt.Rows.Count)
                            {
                                retTable = iCOAReturn.GetProductTable("", UserId, station, Customer, hidFileName.Value, ret, true);
                            }
                            else
                            {
                                iCOAReturn.GetProductTable("", UserId, station, Customer, hidFileName.Value, ret, false);
                            }
                            ret = new List<string>();
                        }
                    }
                }
            }
            if (ret.Count > 0)
            {
                retTable = iCOAReturn.GetProductTable("", UserId, station, Customer, hidFileName.Value, ret, true);
            }
            if (retTable.reValue == "true")
            {
                if (retTable.validProduct.Count > 0)
                {
                    DataTable dtV = initTableV();
                    DataRow newRow;

                    int cnt = 0;

                    foreach (S_RowData_COAReturn ele in retTable.validProduct)
                    {
                        newRow = dtV.NewRow();
                        newRow["SN"] += ele.SN;
                        newRow["COA"] += ele.COAorError;
                        dtV.Rows.Add(newRow);
                        cnt++;
                    }

                    for (; cnt < fullRowCount; cnt++)
                    {
                        newRow = dtV.NewRow();
                        dtV.Rows.Add(newRow);
                    }

                    this.gridviewV.DataSource = dtV;
                    this.gridviewV.DataBind();
                    updatePanelV.Update();
                    initTableColumnHeaderV();
                }
                if (retTable.inValidProduct.Count > 0)
                {
                    DataTable dtE = initTableE();
                    DataRow newRow;
                    int cnt = 0;
                    foreach (S_RowData_COAReturn ele in retTable.inValidProduct)
                    {
                        newRow = dtE.NewRow();
                        newRow["SN"] += ele.SN;
                        newRow["ERROR"] += ele.COAorError;
                        dtE.Rows.Add(newRow);
                        cnt++;
                    }

                    for (; cnt < fullRowCount; cnt++)
                    {
                        newRow = dtE.NewRow();
                        dtE.Rows.Add(newRow);
                    }

                    this.gridviewE.DataSource = dtE;
                    this.gridviewE.DataBind();
                    updatePanelE.Update();
                    initTableColumnHeaderE();
                }
            }
        }
        catch (FisException ee)
        {
            showErrorMessage(ee.mErrmsg);
            return;
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("Cannot find table 0") >= 0)
            {
                showErrorMessage(msgFileEmpty);
            }
            else
            {
                showErrorMessage(ex.Message);
            }
            return;
        }
    }