Example #1
0
 /// <summary>
 /// 更新一筆記錄
 /// </summary>
 /// <returns></returns>
 public void UpdateSpecialOrder(SpecialOrderInfo sepcialOrder)
 {
     try
     {
         DeliveryRepository.UpdateSpecialOrder(sepcialOrder);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
 protected void btnAdd_ServerClick(Object sender, EventArgs e)
 {
     SpecialOrderInfo item = new SpecialOrderInfo();
     SpecialOrderStatus OrderStatus = SpecialOrderStatus.Created;
     item.Editor = this.HiddenUserName.Value;
     item.FactoryPO = this.txtFactoryPO.Value.Trim();
     item.Category = this.dCategory.Value.Trim();
     item.AssetTag = this.txtAssetTag.Value.Trim();
     item.Qty = Convert.ToInt32(this.txtQty.Value);
     item.Status = OrderStatus;
     item.Remark = this.txtRemark.Value.Trim();
     try
     {
         if (iSpecialOrder.ExistSpecialOrder(item.FactoryPO))
         {
             showErrorMessage("[" + item.FactoryPO + "]:此FactoryPO已經存在...");
             return;
         }
         else
         {
             iSpecialOrder.InsertSpecialOrder(item);
         }
     }
     catch (FisException ex)
     {
         showErrorMessage(ex.mErrmsg);
         return;
     }
     catch (Exception ex)
     {
         //show error
         showErrorMessage(ex.Message);
         return;
     }
     btnQuery_ServerClick(sender, e);
     this.updatePanel1.Update();
     ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "AddUpdateComplete('" + item.FactoryPO + "');DealHideWait();", true);
 }
    protected void btnOK_ServerClick(Object sender, EventArgs e)
    {
        string fullFileName = "";
        try
        {
            DataTable dt = new DataTable();
            if (dFileUpload.FileName.Trim() == "")
            {
                pmtMessage4 = this.GetLocalResourceObject(Pre + "_pmtMessage4").ToString();
                showErrorMessage(pmtMessage4);
                return;
            }            
            if (dFileUpload.HasFile)
            {
                string fileName = dFileUpload.FileName;
                string filePath = HttpContext.Current.Server.MapPath("~");
                string path = filePath + "\\tmp";                
                //根下tmp目录存上传临时文件
                MakeDirIfNotExist(path);                
                try
                {
                    string extName = fileName.Substring(fileName.LastIndexOf("."));
                    //if (extName != ".xls")
                    //{
                    //    pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString();
                    //    showErrorMessage(pmtMessage2);
                    //    return;
                    //}
                    ////////////////////
                    Guid guid = System.Guid.NewGuid();
                    fullFileName = path + "\\" + guid.ToString() + extName;
                    dFileUpload.PostedFile.SaveAs(fullFileName);
                    dt = ExcelManager.getExcelSheetData(fullFileName);
                }
                catch
                {
                    pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString();
                    showErrorMessage(pmtMessage2);
                    return;
                }
                int startRow = EXCEL_DATA_START_ROW;
                int endRow = dt.Rows.Count + startRow;
                if (endRow < startRow)
                {
                    pmtMessage3 = this.GetLocalResourceObject(Pre + "_pmtMessage3").ToString();                    
                    showErrorMessage(pmtMessage3);
                    return;
                }

                List<SpecialOrderInfo> importList = new List<SpecialOrderInfo>();
                int iRowsCountNPOI = dt.Rows.Count;
                Dictionary<string, int> modelInList = new Dictionary<string, int>();
                List<string> Assettag = new List<string>();

                for (int iRow = 1; iRow < iRowsCountNPOI; iRow++)
                {
                    int lineNum = iRow + EXCEL_DATA_START_ROW - 1;
                    string Value1NPOI = dt.Rows[iRow][0].ToString();
                    string Value2NPOI = dt.Rows[iRow][1].ToString();
                    string Value3NPOI = dt.Rows[iRow][2].ToString();
                    if (Value1NPOI == "" && Value2NPOI == "" && Value3NPOI == "")
                    {
                        continue;
                    }
                    if (Value1NPOI == "" || Value2NPOI == "" || Value3NPOI == "")
                    {
                        pmtMessage5= this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString();
                        string tmpMessage = pmtMessage5 + " " + lineNum.ToString();
                        showErrorMessage(tmpMessage);
                        return;
                    }
                    int outValue;
                    if (Int32.TryParse(Value2NPOI, out outValue) != true)
                    {
                        pmtMessage5 = this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString();
                        string tmpMessage = pmtMessage5 + " " + lineNum.ToString();
                        showErrorMessage(tmpMessage);
                        return;
                    }
                    if (modelInList.ContainsKey(Value1NPOI) == false)
                    {
                        modelInList.Add(Value1NPOI, outValue);
                        Assettag.Add(Value3NPOI);
                    }
                    else
                    {
                        //int currentNum = modelInList[Value1NPOI] + outValue;
                        //modelInList[Value1NPOI] = currentNum;
                        showErrorMessage("上傳資料重複:第"+ lineNum+"行,『" + Value1NPOI + "』");
                        return;
                    }
                }
                int count = 0;
                foreach (KeyValuePair<string, int> kvp in modelInList)
                {
                    SpecialOrderInfo item = new SpecialOrderInfo();
                    SpecialOrderStatus Status = SpecialOrderStatus.Created;
                    item.FactoryPO = kvp.Key;
                    item.Qty = kvp.Value;
                    item.AssetTag = Assettag[count];
                    item.Editor = this.HiddenUserName.Value;
                    item.Category = this.HidCategory.Value;
                    item.Status = Status;
                    item.Remark = "";
                    importList.Add(item);
                    count++;
                }
                if (importList.Count < 1)
                {
                    pmtMessage3 = this.GetLocalResourceObject(Pre + "_pmtMessage3").ToString();
                    showErrorMessage(pmtMessage3);
                    return;
                }
                IList<string> List = iSpecialOrder.InsertSpecialOrder(importList);
                string dataString="";
                ListToString(List, ref dataString);
                this.dUploadTableResultData.Value = dataString;
            }
            else
            {
                pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString();
                showErrorMessage(pmtMessage2);
                return;
            }
        }
        catch (FisException ex)
        {
            showErrorMessage(ex.mErrmsg);
            return;
        }
        catch (Exception ex)
        {
            //show error
            showErrorMessage(ex.Message);
            return;
        }
        finally
        {
            TryDeleteTempFile(fullFileName);
        }
        ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "OKComplete", "OKComplete();DealHideWait();", true);
    }