Exemplo n.º 1
0
        public List <TypeAndState> DataTableToList(DataTable dt)
        {
            List <TypeAndState> list = new List <TypeAndState>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    TypeAndState item = new TypeAndState();
                    if ((dt.Rows[i]["guid"] != null) && (dt.Rows[i]["guid"].ToString() != ""))
                    {
                        item.guid = new Guid(dt.Rows[i]["guid"].ToString());
                    }
                    if ((dt.Rows[i]["code"] != null) && (dt.Rows[i]["code"].ToString() != ""))
                    {
                        item.code = dt.Rows[i]["code"].ToString();
                    }
                    if ((dt.Rows[i]["Name"] != null) && (dt.Rows[i]["Name"].ToString() != ""))
                    {
                        item.Name = dt.Rows[i]["Name"].ToString();
                    }
                    if ((dt.Rows[i]["ParentGuid"] != null) && (dt.Rows[i]["ParentGuid"].ToString() != ""))
                    {
                        item.ParentGuid = new Guid(dt.Rows[i]["ParentGuid"].ToString());
                    }
                    if ((dt.Rows[i]["Type"] != null) && (dt.Rows[i]["Type"].ToString() != ""))
                    {
                        item.Type = new int?(int.Parse(dt.Rows[i]["Type"].ToString()));
                    }
                    list.Add(item);
                }
            }
            return(list);
        }
Exemplo n.º 2
0
    private string GetTypeOrStateName(Guid guid)
    {
        TypeAndStateBll typeAndStateBll = new TypeAndStateBll();
        TypeAndState    model           = typeAndStateBll.GetModel(guid);

        return(model.Name);
    }
Exemplo n.º 3
0
 private void InitUpdate()
 {
     if (!string.IsNullOrEmpty(this.typeId))
     {
         this.model                 = new TypeAndState();
         this.model                 = this.TASBLL.GetModel(new Guid(this.typeId));
         this.txtName.Text          = this.model.Name.ToString();
         this.txtCode.Text          = this.model.code;
         this.txtCode.Enabled       = false;
         this.HidenTypeNumber.Value = this.model.Type.ToString();
     }
 }
Exemplo n.º 4
0
 protected void addBtn_Click(object sender, EventArgs e)
 {
     if (string.Compare(this.action, "Add", true) == 0)
     {
         this.model      = new TypeAndState();
         this.model.guid = default(Guid);
         this.model.Name = this.txtName.Text.ToString().Trim();
         if (this.HidenTypeNumber.Value.ToString() != "")
         {
             this.model.Type = new int?(int.Parse(this.HidenTypeNumber.Value.ToString()));
         }
         else
         {
             this.model.Type = new int?(int.Parse(this.RadioButtonList1.SelectedValue.ToString()));
         }
         this.model.code       = this.txtCode.Text.ToString().Trim();
         this.model.ParentGuid = new Guid(this.hidenPTID.Value.ToString());
         try
         {
             if (this.txtName.Text.ToString().Trim() != "")
             {
                 DataTable list = this.TASBLL.GetList("Name= '" + this.txtName.Text.ToString().Trim() + "'");
                 if (list != null && list.Rows.Count > 0)
                 {
                     base.RegisterScript("top.ui.alert('类型名称已经存在')");
                 }
                 else
                 {
                     this.TASBLL.Add(this.model);
                     base.RegisterScript("successed();");
                 }
             }
             return;
         }
         catch (Exception)
         {
             base.RegisterScript("top.ui.alert('添加失败')");
             return;
         }
     }
     this.model      = new TypeAndState();
     this.model      = this.TASBLL.GetModel(new Guid(this.typeId));
     this.model.Name = this.txtName.Text.ToString().Trim();
     this.model.code = this.txtCode.Text.ToString().Trim();
     this.model.Type = new int?(int.Parse(this.HidenTypeNumber.Value.ToString()));
     if (this.TASBLL.Update(this.model))
     {
         base.RegisterScript("successed();");
         return;
     }
     base.RegisterScript("top.ui.alert('更新失败')");
 }
Exemplo n.º 5
0
        public void Add(TypeAndState model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into OA_Vehicle_TypeAndState(");
            builder.Append("guid,code,Name,ParentGuid,Type)");
            builder.Append(" values (");
            builder.Append("@guid,@code,@Name,@ParentGuid,@Type)");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@guid", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@code", SqlDbType.NVarChar, 100), new SqlParameter("@Name", SqlDbType.NVarChar, 100), new SqlParameter("@ParentGuid", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@Type", SqlDbType.Int, 4) };
            commandParameters[0].Value = Guid.NewGuid();
            commandParameters[1].Value = model.code;
            commandParameters[2].Value = model.Name;
            commandParameters[3].Value = model.ParentGuid;
            commandParameters[4].Value = model.Type;
            SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters);
        }
Exemplo n.º 6
0
    private void InitAdd()
    {
        DateTime now = DateTime.Now;

        this.txtCode.Text    = now.ToString("yyyyMMdd") + now.Millisecond.ToString();
        this.txtCode.Enabled = false;
        if (this.priGuid != "")
        {
            TypeAndState typeAndState = this.TASBLL.GetModel(new Guid(this.priGuid));
            string       text         = string.Empty;
            if (typeAndState != null)
            {
                text = typeAndState.Type.ToString();
                this.HidenTypeNumber.Value = text.ToString();
                this.hidenPTID.Value       = this.priGuid;
                return;
            }
            if (this.priGuid == "00000000-0000-0000-0000-000000000000")
            {
                List <TypeAndState> modelList = this.TASBLL.GetModelList("ParentGuid='00000000-0000-0000-0000-000000000000'");
                if (modelList.Count >= 2)
                {
                    this.txtName.Enabled = true;
                    this.trr.Visible     = false;
                    this.btnSave.Enabled = true;
                }
                else
                {
                    this.txtName.Enabled = true;
                    this.trr.Visible     = true;
                }
                this.RadioButtonList1.Items[0].Selected = true;
                for (int i = 0; i < modelList.Count; i++)
                {
                    if (modelList[i].Type == 1)
                    {
                        this.RadioButtonList1.Items[0].Selected = true;
                    }
                    else
                    {
                        this.RadioButtonList1.Items[1].Selected = true;
                    }
                }
            }
        }
    }
Exemplo n.º 7
0
        public bool Update(TypeAndState model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update OA_Vehicle_TypeAndState set ");
            builder.Append("code=@code,");
            builder.Append("Name=@Name,");
            builder.Append("ParentGuid=@ParentGuid,");
            builder.Append("Type=@Type");
            builder.Append(" where guid=@guid ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@code", SqlDbType.NVarChar, 100), new SqlParameter("@Name", SqlDbType.NVarChar, 100), new SqlParameter("@ParentGuid", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@Type", SqlDbType.Int, 4), new SqlParameter("@guid", SqlDbType.UniqueIdentifier, 0x10) };
            commandParameters[0].Value = model.code;
            commandParameters[1].Value = model.Name;
            commandParameters[2].Value = model.ParentGuid;
            commandParameters[3].Value = model.Type;
            commandParameters[4].Value = model.guid;
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters) > 0);
        }
Exemplo n.º 8
0
 public bool Update(TypeAndState model)
 {
     return(this.dal.Update(model));
 }
Exemplo n.º 9
0
 public void Add(TypeAndState model)
 {
     this.dal.Add(model);
 }