Beispiel #1
0
        protected void btnAddEngunit_Click(object sender, EventArgs e)
        {
            int index = EngunitDal.EngunitIDCounts();

            string sID = PageControl.GetGuid();

            EngunitEntity ote = new EngunitEntity();

            ote.EngunitID         = sID;
            ote.EngunitName       = "Input Name";
            ote.EngunitDesc       = "";
            ote.EngunitNote       = "";
            ote.EngunitCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
            ote.EngunitModifyTime = ote.EngunitCreateTime;

            if (EngunitDal.Insert(ote))
            {
                //MessageBox.popupClientMessage(this.Page, "添加成功!", "call();");
            }
            else
            {
                MessageBox.popupClientMessage(this.Page, "添加错误!", "call();");
            }

            gvEngunit.EditIndex = index;

            BindGrid();
        }
Beispiel #2
0
        protected void gvEngunit_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string keyid = ((HtmlInputHidden)(gvEngunit.Rows[e.RowIndex].Cells[0].FindControl("engunitid"))).Value;

            string eName = ((TextBox)(gvEngunit.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
            string eDesc = ((TextBox)(gvEngunit.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim();
            string eNote = ((TextBox)(gvEngunit.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim();

            string msg = "";

            if (eName == "")
            {
                msg += "名称不能为空!\r\n";
            }

            if (msg != "")
            {
                MessageBox.popupClientMessage(this.Page, msg);
                return;
            }

            if (EngunitDal.EngunitExist(eName, keyid))
            {
                MessageBox.popupClientMessage(this.Page, "该单位已存在!", "call();");
                return;
            }


            EngunitEntity mEntity = new EngunitEntity();

            mEntity.EngunitID   = keyid;
            mEntity.EngunitName = eName;
            mEntity.EngunitDesc = eDesc;
            mEntity.EngunitNote = eNote;

            //mEntity.EngunitCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
            mEntity.EngunitModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");

            if (!EngunitDal.Update(mEntity))
            {
                MessageBox.popupClientMessage(this.Page, "编辑错误!", "call();");
            }
            else
            {
                MessageBox.popupClientMessage(this.Page, "编辑成功!", "call();");

                gvEngunit.EditIndex = -1;

                BindGrid();
            }
        }