Example #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(docGROUPNAME.Text))
            {
                Alert.Show("请输入模板名称!", "警告提醒", MessageBoxIcon.Warning);
                return;
            }
            if (docGROUPNAME.Text.Length > 50)
            {
                Alert.Show("输入的模板名称超过字数限制!", "警告提醒", MessageBoxIcon.Warning);
                return;
            }
            if (ddlTYPE.SelectedValue == "")
            {
                Alert.Show("请选择申请模板!", "警告提醒", MessageBoxIcon.Warning);
                return;
            }


            if (hfdGROUPID.Text == "")
            {
                hfdGROUPID.Text = GetCode();
            }

            List <Dictionary <string, object> > newDict = GridGoods.GetNewAddedList().ToList();
            MyTable mt = new MyTable("DOC_GROUPDOC");

            mt.ColRow = PubFunc.FormDataHT(FormCond);
            //string type = ddlTYPE.SelectedValue;
            //mt.ColRow.Add("TYPE", "T");
            mt.ColRow.Add("SUBNUM", newDict.Count);
            mt.ColRow.Add("LRY", UserAction.UserID);
            List <CommandInfo> cmdList  = new List <CommandInfo>();
            MyTable            mtTypeMx = new MyTable("DOC_GROUPCOM");

            //先删除单据信息在插入
            cmdList.Add(new CommandInfo("DELETE DOC_GROUPDOC WHERE GROUPID='" + hfdGROUPID.Text + "'", null)); //删除单据台头
            cmdList.Add(new CommandInfo("DELETE DOC_GROUPCOM WHERE GROUPID='" + hfdGROUPID.Text + "'", null)); //删除单据明细
            cmdList.AddRange(mt.InsertCommand());
            for (int i = 0; i < newDict.Count; i++)
            {
                int num = Convert.ToInt32(newDict[i]["SL"]);
                if (num < 1)
                {
                    Alert.Show("申请数量不能为0!", "警告提醒", MessageBoxIcon.Warning);
                    return;
                }
                mtTypeMx.ColRow = PubFunc.GridDataGet(newDict[i]);
                mtTypeMx.ColRow.Remove("ROWNO");
                mtTypeMx.ColRow.Add("ROWNO", i + 1);
                mtTypeMx.ColRow.Add("GROUPID", hfdGROUPID.Text);
                cmdList.Add(mtTypeMx.Insert());
            }
            if (DbHelperOra.ExecuteSqlTran(cmdList))
            {
                Alert.Show("模板信息保存成功!", "消息提示", MessageBoxIcon.Information);
                //DataInit();
                GridStrategy.DataSource = GridTemplate("");
                GridStrategy.DataBind();
            }
        }