Esempio n. 1
0
        protected void cmdImport_ServerClick(object sender, System.EventArgs e)
        {
            if (items == null)
            {
                items = GetAllItem();
                if (items == null)
                {
                    return;
                }
            }
            if (items == null || items.Length == 0)
            {
                return;
            }

            int    successNum = 0;
            int    failNum    = 0;
            string objValue   = string.Empty;

            DBDateTime now          = FormatHelper.GetNowDBDateTime(this.DataProvider);
            string     maintainUser = this.GetUserCode();

            for (int i = 0; i < items.Length; i++)
            {
                if (string.Compare(GetFieldValue(items[i], "ValidateResult"), "OK", true) == 0)
                {
                    string   moCode   = GetFieldValue(items[i], "MOCode");
                    MOFacade moFacade = new MOFacade(this.DataProvider);
                    object   obj      = moFacade.GetMO(moCode);
                    MO       objMo    = obj as MO;

                    /*---------------------------  CSV中数据(如果是空,则不更新对应的栏位) ---------------------------*/
                    objValue = GetFieldValue(items[i], "MOPlanQty1");
                    if (objValue != string.Empty)
                    {
                        objMo.MOPlanQty = decimal.Parse(objValue);  //MOPlanQty
                    }

                    objValue = GetFieldValue(items[i], "MOMemo1");
                    if (objValue != string.Empty)
                    {
                        objMo.MOMemo = objValue;  //MOMemo
                    }

                    objValue = GetFieldValue(items[i], "BOMVersion1");
                    if (objValue != string.Empty)
                    {
                        objMo.BOMVersion = objValue;  //BOMVersion
                    }

                    objValue = GetFieldValue(items[i], "MOPlanStartDate1");
                    if (objValue != string.Empty)
                    {
                        objMo.MOPlanStartDate = int.Parse(objValue); //MOPlanStartDate
                    }

                    objValue = GetFieldValue(items[i], "MOPlanStartTime");
                    if (objValue != string.Empty)
                    {
                        objMo.MOPlanStartTime = int.Parse(objValue);  //MOPlanStartTime
                    }

                    objValue = GetFieldValue(items[i], "MOPlanEndDate1");
                    if (objValue != string.Empty)
                    {
                        objMo.MOPlanEndDate = int.Parse(objValue);  //MOPlanEndDate
                    }

                    objValue = GetFieldValue(items[i], "MOPlanEndTime");
                    if (objValue != string.Empty)
                    {
                        objMo.MOPlanEndTime = int.Parse(objValue);  //MOPlanEndTime
                    }

                    objValue = GetFieldValue(items[i], "MOPlanLine");
                    if (objValue != string.Empty)
                    {
                        objMo.MOPlanLine = objValue;  //MOPlanLine
                    }

                    objValue = GetFieldValue(items[i], "CustomerCode");
                    if (objValue != string.Empty)
                    {
                        objMo.CustomerCode = objValue;   //CustomerCode
                    }

                    objValue = GetFieldValue(items[i], "CustomerName");
                    if (objValue != string.Empty)
                    {
                        objMo.CustomerName = objValue;  //CustomerName
                    }

                    objValue = GetFieldValue(items[i], "CustomerOrderNO1");
                    if (objValue != string.Empty)
                    {
                        objMo.CustomerOrderNO = objValue;  //CustomerOrderNO
                    }

                    objValue = GetFieldValue(items[i], "CustomerItemCode");
                    if (objValue != string.Empty)
                    {
                        objMo.CustomerItemCode = objValue;  //CustomerItemCode
                    }

                    objValue = GetFieldValue(items[i], "OrderNO");
                    if (objValue != string.Empty)
                    {
                        objMo.OrderNO = objValue;  //OrderNO
                    }

                    objValue = GetFieldValue(items[i], "OrderSequence1");
                    if (objValue != string.Empty)
                    {
                        objMo.OrderSequence = decimal.Parse(objValue);  //OrderSequence
                    }

                    objValue = GetFieldValue(items[i], "EAttribute1");
                    if (objValue != string.Empty)
                    {
                        objMo.EAttribute1 = objValue;  //EAttribute1
                    }

                    objValue = GetFieldValue(items[i], "EAttribute4");
                    if (objValue != string.Empty)
                    {
                        objMo.EAttribute4 = objValue;  //EAttribute4
                    }

                    objValue = GetFieldValue(items[i], "EAttribute5");
                    if (objValue != string.Empty)
                    {
                        objMo.EAttribute5 = objValue;  //EAttribute5
                    }

                    objValue = GetFieldValue(items[i], "EAttribute6");
                    if (objValue != string.Empty)
                    {
                        objMo.EAttribute6 = objValue;  //EAttribute6
                    }

                    objMo.MaintainDate = now.DBDate;
                    objMo.MaintainTime = now.DBTime;
                    objMo.MaintainUser = maintainUser;

                    moFacade.UpdateMO(objMo, false);

                    successNum++;
                }
                else
                {
                    failNum++;
                }
            }

            //string strMessage = languageComponent1.GetString("导入完成: 成功" + successNum + "笔, 失败" + failNum + "笔");
            string strMessage = "导入完成: 成功" + successNum + "笔, 失败" + failNum + "笔";
            string alertInfo  =
                string.Format("<script language=javascript>alert('{0}');</script>", strMessage);

            if (!this.IsClientScriptBlockRegistered("ImportAlert"))
            {
                this.RegisterClientScriptBlock("ImportAlert", alertInfo);
            }
            items = null;
            this.cmdEnter.Disabled = true;
        }