Exemplo n.º 1
0
        private void LineRename_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var row = ComboTemperature.SelectedItem as DataRowView;

            if (row == null)
            {
                return;
            }


            var temperature = new Sys_Temperature()
            {
                ID           = Convert.ToInt32(row.Row["ID"]),
                TestRoomCode = Convert.ToString(row.Row["TestRoomCode"]),
                CreateTime   = Convert.ToString(row.Row["CreateTime"]),
                CreateBy     = Convert.ToString(row.Row["CreateBy"]),
                IsSystem     = Convert.ToInt32(row.Row["IsSystem"]),
                Name         = Convert.ToString(row.Row["Name"])
            };

            var form = new TemperatureEditor(temperature);

            if (form.ShowDialog() == DialogResult.OK)
            {
                ComboTemperature.DataSource = TemperatureHelperClient.GetTemperatureTypes(TestRoomCode);
            }
        }
Exemplo n.º 2
0
        public string NewTemperature(Sys_Temperature temperature)
        {
            if (ExistsTemperatureName(temperature.TestRoomCode, temperature.Name))
            {
                return("温度类型的名称不可以重复");
            }

            var sql = @"INSERT INTO [dbo].[sys_temperature_types]
                       ([ID]
	                   ,[TestRoomCode]
                       ,[CreateBy]
                       ,[CreateTime]
                       ,[Name]
                       ,[IsSystem])
                 VALUES(
                       (SELECT MAX(ID) FROM dbo.sys_temperature_types) + 1 ,
                       @TestRoomCode,
                       @CreateBy, 
                       @CreateTime,
                       @Name, 
                       @IsSystem)";

            var connection = GetConntion();

            connection.Open();

            var command = GetDbCommand(sql, connection);

            command.Parameters.Clear();
            command.Parameters.Add(new SqlParameter("@TestRoomCode", temperature.TestRoomCode));
            command.Parameters.Add(new SqlParameter("@CreateBy", temperature.CreateBy));
            command.Parameters.Add(new SqlParameter("@CreateTime", DateTime.Now));
            command.Parameters.Add(new SqlParameter("@IsSystem", temperature.IsSystem));
            command.Parameters.Add(new SqlParameter("@Name", temperature.Name));

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return("添加失败");
            }

            return(null);
        }
Exemplo n.º 3
0
        private void New()
        {
            if (string.IsNullOrEmpty(TextName.Text))
            {
                MessageBox.Show("请输入温度类型名称");
                TextName.Focus();
                return;
            }

            Temperature = new Sys_Temperature()
            {
                IsSystem   = (Yqun.Common.ContextCache.ApplicationContext.Current.IsAdministrator && CheckIsSystem.Checked) ? 1 : 0,
                Name       = TextName.Text,
                CreateBy   = Yqun.Common.ContextCache.ApplicationContext.Current.UserName,
                CreateTime = DateTime.Now.ToString("yyyy-MM-dd hh:MM:ss"),
            };

            if (Yqun.Common.ContextCache.ApplicationContext.Current.IsAdministrator)
            {
                if (string.IsNullOrEmpty(TestRoomCode))
                {
                    Temperature.TestRoomCode = "0000000000000000";
                }
                else
                {
                    Temperature.TestRoomCode = TestRoomCode;
                }
            }
            else
            {
                Temperature.TestRoomCode = Yqun.Common.ContextCache.ApplicationContext.Current.InTestRoom.Code;
            }

            var result = TemperatureHelperClient.NewTemperature(Temperature);

            if (string.IsNullOrEmpty(result))
            {
                MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 4
0
 public TemperatureEditor(Sys_Temperature temperature)
 {
     InitializeComponent();
     Temperature = temperature;
 }
Exemplo n.º 5
0
 internal static string NewTemperature(Sys_Temperature temperature)
 {
     return(Agent.CallService("Yqun.BO.BusinessManager.dll", "NewTemperature", new object[] { temperature }) as string);
 }