private DetectPointEntity CreateACDectectPoint(DeviceFunctionEntity fun, string cmdcode, double standardvalue, string cmdrange, string cmdfun, string cmdres, double testrange, string unit, int idnum,double fvalue,string funit) { DetectPointEntity _r = new DetectPointEntity(); _r.DataTable_Action_ = DataTable_Action.Insert; _r.ID = idnum; _r.DelFlag = false; _r.Frequency = fvalue; _r.FrequencyUnit = funit; _r.FunctionCode = fun.FunctionCode; _r.FunctionID = fun.ID; _r.H_PerMissibleError = 0; _r.ChangePerMissibleError = 0; _r.Inputter = UserData.GetUserDate.UserID; _r.InputTime = DateTime.Now; _r.MissibleErrorSymbol = "±"; _r.OrderID = GetNewDetectcPointOrderID(fun); _r.RoundLen = _Device.RoundLen; _r.SetCmdPerfix = _Device.SetCmdPerfix; _r.SetCmdSuffix = _Device.SetCmdSuffix; _r.CommandCode = cmdcode; _r.State = 1; _r.StandardValue = standardvalue; _r.SwichRangeCmdCode = cmdrange; _r.SwitchFuncCmdCode = cmdfun; _r.SwitchRESCmdCode = cmdres; _r.TestRange = testrange; _r.Unit = unit; PermitErrorCalculator calculator = new PermitErrorCalculator(); _r.ValuePerMissibleErrorName = calculator.GetPermitError(_Device, _r); idnum--; return _r; }
/// <summary> /// 增加/修改事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string symbol_Value = MissibleErrorSymbol_DropDown.SelectedValue; double StandardValue_Value = Convert.ToDouble(Common.sink(StandardValue_Input.UniqueID, MethodType.Post, 53, 0, DataType.Double)); double ChangePerMissibleError_Value = Convert.ToDouble(Common.sink(ChangePerMissibleError_Input.UniqueID, MethodType.Post, 53, 0, DataType.Double)); double H_PerMissibleError_Value = Convert.ToDouble(Common.sink(H_PerMissibleError_Input.UniqueID, MethodType.Post, 53, 0, DataType.Double)); string SwichRangeCmdCode_Value = ((string)Common.sink(SwichRangeCmdCode_Input.UniqueID, MethodType.Post, 50, 0, DataType.Str)).Trim(); string SwichFuncCmdCode_Value = ((string)Common.sink(SwichFuncCmdCode_Input.UniqueID, MethodType.Post, 50, 0, DataType.Str)).Trim(); string SwichRESCmdCode_Value = ((string)Common.sink(SwichRESCmdCode_Input.UniqueID, MethodType.Post, 50, 0, DataType.Str)).Trim(); double TestRange_Value = Convert.ToDouble(Common.sink(TestRange_Input.UniqueID, MethodType.Post, 53, 0, DataType.Double)); double Frequency_Value = Convert.ToDouble(Common.sink(Frequency_Input.UniqueID, MethodType.Post, 53, 0, DataType.Double)); string FrequencyUnit_Value = ((string)Common.sink(FrequencyUnit_Input.UniqueID, MethodType.Post, 50, 0, DataType.Str)).Trim(); string Unit_Value = ((string)Common.sink(Unit_Input.UniqueID, MethodType.Post, 50, 0, DataType.Str)).Trim(); string SetCmdPerfix_Value = ((string)Common.sink(SetCmdPerfix_Input.UniqueID, MethodType.Post, 50, 0, DataType.Str)).Trim(); string SetCmdSuffix_Value = ((string)Common.sink(SetCmdSuffix_Input.UniqueID, MethodType.Post, 50, 0, DataType.Str)).Trim(); int RoundLen_Value = 0;// (int)Common.sink(RoundLen_Input.UniqueID, MethodType.Post, 10, 0, DataType.Int); // double ValuePerMissibleErrorName_Value = Math.Abs(Convert.ToDouble(Common.sink(ValuePerMissibleErrorName_Input.UniqueID, MethodType.Post, 53, 0, DataType.Double))); int ValuePerMissible_Fraction_Value = Convert.ToInt32(Common.sink(ValuePerMissibleErrorName_Fraction_Input.UniqueID, MethodType.Post, 53, 0, DataType.Int)); DeviceEntity device = BusinessFacadeShanliTech_HLD_Business.DeviceDisp(DeviceID); //单位微伏等由u替换µ Unit_Value = Unit_Value.Replace("u", "µ"); int FunctionID_Value = FunctionID; string FunctionCode_Value = string.Empty; string CommandCode_Value = string.Empty; if (FunctionID_Value > 0) { FunctionCode_Value = BusinessFacadeShanliTech_HLD_Business.DeviceFunctionDisp(FunctionID_Value).FunctionCode; CommandCode_Value = CommonUtils.GetCommandStr(StandardValue_Value, Unit_Value, Frequency_Value, FrequencyUnit_Value, FunctionCode_Value); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert1", "<script>alert('请选择对应设备功能');</script>"); return; } //RoundLen_Value==0则取所属设备的属性RoundLen值 RoundLen_Value = device.RoundLen; if (ValuePerMissibleErrorName_Value.ToString().ToUpper().IndexOf("E") >= 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert1", string.Format("<script>alert('请正确填写最大允许误差底数!不应包含指数形式:{0}');</script>", ValuePerMissibleErrorName_Value.ToString())); return; } double per = 0; Double.TryParse(NumberFormatUtils.ToSicenOneFractionStr(Convert.ToDouble(ValuePerMissibleErrorName_Value.ToString() + "E" + ValuePerMissible_Fraction_Value.ToString())), out per); DetectPointEntity ut = BusinessFacadeShanliTech_HLD_Business.DetectPointDisp(IDX); ut.CommandCode = CommandCode_Value; ut.FunctionCode = FunctionCode_Value; ut.StandardValue = StandardValue_Value; ut.ChangePerMissibleError = ChangePerMissibleError_Value; ut.H_PerMissibleError = H_PerMissibleError_Value; ut.TestRange = TestRange_Value; ut.Unit = Unit_Value; ut.FunctionID = FunctionID_Value; ut.DelFlag = false; ut.Inputter = UserData.GetUserDate.UserID; ut.InputTime = DateTime.Now; ut.State = 0; ut.Frequency = Frequency_Value; ut.FrequencyUnit = (string.IsNullOrEmpty(FrequencyUnit_Value) ? "Hz" : FrequencyUnit_Value); ut.MissibleErrorSymbol = symbol_Value; ut.SetCmdSuffix = SetCmdSuffix_Value; ut.SetCmdPerfix = SetCmdPerfix_Value; ut.RoundLen = RoundLen_Value; ut.SwichRangeCmdCode = SwichRangeCmdCode_Value; ut.SwitchFuncCmdCode=SwichFuncCmdCode_Value; ut.SwitchRESCmdCode = SwichRESCmdCode_Value; if (per == 0) { PermitErrorCalculator calculator = new PermitErrorCalculator(); ut.ValuePerMissibleErrorName = calculator.GetPermitError(device, ut); } else { ut.ValuePerMissibleErrorName = per; } if (CMD == "New") { ut.DataTable_Action_ = DataTable_Action.Insert; ut.OrderID = ToolMethods.GetMaxOrderIdPoint(FunctionID) + 1; } else if (CMD == "Edit") { ut.DataTable_Action_ = DataTable_Action.Update; } else { EventMessage.MessageBox(2, "不存在操作字符串!", "不存在操作字符串!", Icon_Type.Error, Common.GetHomeBaseUrl("DefaultPoint.aspx?FunctionID=" + FunctionID + "&DeviceID=" + DeviceID)); } Int32 rInt = BusinessFacadeShanliTech_HLD_Business.DetectPointInsertUpdateDelete(ut); if ( rInt> 0) { string OpTxt = string.Format("增加功能检定点成功!(ID:{0})", rInt); if (ut.DataTable_Action_ == DataTable_Action.Update) OpTxt = string.Format("修改功能检定点成功!(ID:{0})", IDX); EventMessage.MessageBox(1, "操作成功", OpTxt, Icon_Type.OK, Common.GetHomeBaseUrl("DefaultPoint.aspx?FunctionID=" + FunctionID + "&DeviceID=" + DeviceID)); } else if (rInt == -2) { EventMessage.MessageBox(1, "操作失败", "操作失败,存在相同的键值(用户名/数据)!", Icon_Type.Alert, Common.GetHomeBaseUrl("DefaultPoint.aspx?FunctionID=" + FunctionID + "&DeviceID=" + DeviceID)); } else { EventMessage.MessageBox(1, "操作失败", string.Format("操作失败,返回值:{0}!", rInt), Icon_Type.Error, Common.GetHomeBaseUrl("DefaultPoint.aspx?FunctionID=" + FunctionID + "&DeviceID=" + DeviceID)); } }