Exemplo n.º 1
0
        private void Delete(object obj)
        {
            string sqlStr = "delete from shebeiguanli where ";

            int index = 0;

            foreach (var item in tableList)
            {
                if (item.bSel)
                {
                    if (index == 0)
                    {
                        sqlStr += " Shebeiguanli.[Xuhao]=" + item.Xuhao;
                    }
                    else
                    {
                        sqlStr += " or Shebeiguanli.[Xuhao]=" + item.Xuhao;
                    }

                    index++;
                }
            }


            if (index > 0)
            {
                WorkServer.excuteSql(sqlStr, Marshal.GetFunctionPointerForDelegate(_excutesqlCallBackDelegate), true);
                QueryShebeiguanli(null);
            }
        }
Exemplo n.º 2
0
        private void Delete(object obj)
        {
            string sqlStr = "delete from " + tableName + " where ";

            DataGrid grid = obj as DataGrid;

            int index = 0;

            foreach (var item in grid.SelectedItems)
            {
                if (item.GetType() != typeof(YINGSHEBIAOModel))
                {
                    if (index == 0)
                    {
                        sqlStr += " " + tableName + ".[Xuhao]=" + item.GetType().GetProperty("Xuhao").GetValue(item, null);
                    }
                    else
                    {
                        sqlStr += " or" + " " + tableName + ".[Xuhao]=" + item.GetType().GetProperty("Xuhao").GetValue(item, null);
                    }
                }
                else
                {
                    if (index == 0)
                    {
                        sqlStr += " " + tableName + ".[Bianhao]=" + item.GetType().GetProperty("Bianhao").GetValue(item, null);
                    }
                    else
                    {
                        sqlStr += " or" + " " + tableName + ".[Bianhao]=" + item.GetType().GetProperty("Bianhao").GetValue(item, null);
                    }
                }

                index++;
            }


            if (index > 0)
            {
                WorkServer.excuteSql(sqlStr, Marshal.GetFunctionPointerForDelegate(_excutesqlCallBackDelegate), true);
                Query(null);
            }
        }
Exemplo n.º 3
0
        private void Operate(object obj)
        {
            switch (operateenum)
            {
            case OperateEnum.OperateEnum_Add:
            {
                string tableName = "Shebeiguanli";
                int    addCount  = 1;
                Random ran       = new Random();
                Type   type      = typeof(SHEBEIGUANLIModel);

                if (type != null)
                {
                    System.Reflection.PropertyInfo[] properties = type.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

                    DateTime time   = DateTime.Now;
                    string   addXml = "";
                    for (int i = 0; i < addCount; ++i)
                    {
                        foreach (System.Reflection.PropertyInfo item in properties)
                        {
                            if (item.PropertyType.Name.StartsWith("Int32"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                switch (item.Name)
                                {
                                case "Xuhao":
                                    addXml += "0";
                                    break;

                                default:
                                    addXml += item.GetValue(customInfo1, null);
                                    break;
                                }
                            }
                            else if (item.PropertyType.Name.StartsWith("Int64"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                addXml += item.GetValue(customInfo1, null);
                            }
                            else if (item.PropertyType.Name.StartsWith("Single"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                addXml += item.GetValue(customInfo1, null);
                            }
                            else if (item.PropertyType.Name.StartsWith("String"))
                            {
                                addXml += item.Name;
                                addXml += ":";

                                switch (item.Name)
                                {
                                case "Chengshibianhao":
                                case "Jubianhao":
                                case "Shiyongdanweibianhao":
                                {
                                    string temp = (string)item.GetValue(customInfo1, null);
                                    foreach (KeyValuePair <int, string> kvp in MainWindowViewModel._yingshelList)
                                    {
                                        if (kvp.Value == temp)
                                        {
                                            addXml += kvp.Key;
                                        }
                                    }
                                }
                                break;

                                case "IP":
                                {
                                    string    temp = (string)item.GetValue(customInfo1, null);
                                    IPAddress addr;
                                    if (customInfo1.IP != null && customInfo1.IP.Length != 0 && IPAddress.TryParse(temp, out addr))
                                    {
                                        addXml += (UInt32)(IPAddress.HostToNetworkOrder((Int32)Common.IpToInt(temp)));
                                    }
                                }
                                break;

                                case "Chuangjianshijian":
                                    addXml += Common.ConvertDateTimeInt(DateTime.Now);
                                    break;

                                default:
                                    addXml += item.GetValue(customInfo1, null);
                                    break;
                                }
                            }
                            else if (item.PropertyType.Name.StartsWith("Boolean"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                addXml += (i % 2 == 0) ? "0" : "1";
                            }
                            else
                            {
                                ;
                            }
                            addXml += ",";
                        }
                        addXml += ";";
                    }

                    if (tableName != null && tableName.Length != 0)
                    {
                        customInfo1.Xuhao = -1;
                        WorkServer.addTable(tableName, addXml, Marshal.GetFunctionPointerForDelegate(_addtablecallbackdelegate), true);
                        QueryShebeiguanli(null);
                    }
                }
            }
            break;

            case OperateEnum.OperateEnum_Modify:
            {
                string sqlStr = "update shebeiguanli set ";

                int begin = 0;
                foreach (KeyValuePair <int, string> kvp in MainWindowViewModel._yingshelList)
                {
                    if (kvp.Value == customInfo1.Chengshibianhao)
                    {
                        sqlStr += "Chengshibianhao='" + kvp.Key + "'";
                    }
                }

                foreach (KeyValuePair <int, string> kvp in MainWindowViewModel._yingshelList)
                {
                    if (kvp.Value == customInfo1.Jubianhao)
                    {
                        sqlStr += ",Jubianhao='" + kvp.Key + "'";
                    }
                    else if (kvp.Value == customInfo1.Shiyongdanweibianhao)
                    {
                        sqlStr += ",Shiyongdanweibianhao='" + kvp.Key + "'";
                    }
                }


                IPAddress addr;
                if (!string.IsNullOrEmpty(customInfo1.IP) && IPAddress.TryParse(customInfo1.IP, out addr))
                {
                    sqlStr += ",IP='" + (UInt32)(IPAddress.HostToNetworkOrder((Int32)Common.IpToInt(customInfo1.IP))) + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Shebeichangjia))
                {
                    sqlStr += ",Shebeichangjia='" + customInfo1.Shebeichangjia + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Shebeimingcheng))
                {
                    sqlStr += ",Shebeimingcheng='" + customInfo1.Shebeimingcheng + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Shebeileixing))
                {
                    sqlStr += ",Shebeileixing='" + customInfo1.Shebeileixing + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Jingdu))
                {
                    sqlStr += ",Jingdu='" + customInfo1.Jingdu + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Weidu))
                {
                    sqlStr += ",Weidu='" + customInfo1.Weidu + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Ruanjianxinxi))
                {
                    sqlStr += ",Ruanjianxinxi='" + customInfo1.Ruanjianxinxi + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Yingjianxinxi))
                {
                    sqlStr += ",Yingjianxinxi='" + customInfo1.Yingjianxinxi + "'";
                }

                sqlStr += " where ";
                int index = 0;
                foreach (var item in tableList)
                {
                    if (item.bSel)
                    {
                        if (index == 0)
                        {
                            sqlStr += " Shebeiguanli.[Xuhao]=" + item.Xuhao;
                        }
                        else
                        {
                            sqlStr += " or Shebeiguanli.[Xuhao]=" + item.Xuhao;
                        }

                        index++;
                    }
                }

                if (index >= 0)
                {
                    WorkServer.excuteSql(sqlStr, Marshal.GetFunctionPointerForDelegate(_excutesqlCallBackDelegate), true);
                    QueryShebeiguanli(null);
                }
            }
            break;
            }
        }
Exemplo n.º 4
0
        private void Operate(object obj)
        {
            switch (operateenum)
            {
            case OperateEnum.OperateEnum_Add:
            {
                string tableName = "Guanliyuan";
                int    addCount  = 1;
                Random ran       = new Random();
                Type   type      = typeof(GUANLIYUANModel);

                if (type != null)
                {
                    System.Reflection.PropertyInfo[] properties = type.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

                    DateTime time   = DateTime.Now;
                    string   addXml = "";
                    for (int i = 0; i < addCount; ++i)
                    {
                        foreach (System.Reflection.PropertyInfo item in properties)
                        {
                            if (item.PropertyType.Name.StartsWith("Int32"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                switch (item.Name)
                                {
                                case "Xuhao":
                                    addXml += "0";
                                    break;

                                default:
                                    addXml += ran.Next().ToString();
                                    break;
                                }
                            }
                            else if (item.PropertyType.Name.StartsWith("Int64"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                addXml += ran.Next().ToString();
                            }
                            else if (item.PropertyType.Name.StartsWith("Single"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                addXml += ran.Next().ToString();
                            }
                            else if (item.PropertyType.Name.StartsWith("String"))
                            {
                                addXml += item.Name;
                                addXml += ":";

                                switch (item.Name)
                                {
                                case "Youxiaoqikaishi":
                                case "Youxiaoqijieshu":
                                    addXml += Common.ConvertDateTimeInt(DateTime.Parse((string)item.GetValue(customInfo1, null)));

                                    break;

                                default:
                                    addXml += item.GetValue(customInfo1, null);
                                    break;
                                }
                            }
                            else if (item.PropertyType.Name.StartsWith("Boolean"))
                            {
                                addXml += item.Name;
                                addXml += ":";
                                addXml += (i % 2 == 0) ? "0" : "1";
                            }
                            else
                            {
                                ;
                            }
                            addXml += ",";
                        }
                        addXml += ";";
                    }

                    if (tableName != null && tableName.Length != 0)
                    {
                        WorkServer.addTable(tableName, addXml, Marshal.GetFunctionPointerForDelegate(_addtablecallbackdelegate), true);
                        QueryYongHuguanli(null);
                    }
                }
            }
            break;

            case OperateEnum.OperateEnum_Modify:
            {
                string sqlStr = "update Guanliyuan set ";


                if (!string.IsNullOrEmpty(customInfo1.Yonghuming))
                {
                    sqlStr += "Yonghuming='" + customInfo1.Yonghuming + "'";
                }
                else
                {
                    return;
                }

                if (!string.IsNullOrEmpty(customInfo1.Mima))
                {
                    sqlStr += ",Mima='" + customInfo1.Mima + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Youxiaoqikaishi))
                {
                    sqlStr += ",Youxiaoqikaishi='" + Common.ConvertDateTimeInt(DateTime.Parse(customInfo1.Youxiaoqikaishi)) + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Youxiaoqijieshu))
                {
                    sqlStr += ",Youxiaoqijieshu='" + Common.ConvertDateTimeInt(DateTime.Parse(customInfo1.Youxiaoqijieshu)) + "'";
                }

                if (!string.IsNullOrEmpty(customInfo1.Quanxianjibie))
                {
                    sqlStr += ",Quanxianjibie='" + customInfo1.Quanxianjibie + "'";
                }

                sqlStr += " where ";
                int index = 0;
                foreach (var item in tableList)
                {
                    if (item.bSel)
                    {
                        if (index == 0)
                        {
                            sqlStr += " Guanliyuan.[Xuhao]=" + item.Xuhao;
                        }
                        else
                        {
                            sqlStr += " or Guanliyuan.[Xuhao]=" + item.Xuhao;
                        }

                        index++;
                    }
                }

                WorkServer.excuteSql(sqlStr, Marshal.GetFunctionPointerForDelegate(_excutesqlCallBackDelegate), true);
                QueryYongHuguanli(null);
            }
            break;
            }
        }