public bool Update(MODELINVOICEBATCH MODELINVOICEBATCH)
        {
            StringBuilder str = new StringBuilder();

            str.Append("UPDATE INVOICEBATCH SET INVOICEBATCHNAME=@INVOICEBATCHNAME,ISUSING=@ISUSING,INVOICEBATCHMEMO=@INVOICEBATCHMEMO ");
            str.Append("WHERE INVOICEBATCHID=@INVOICEBATCHID");
            SqlParameter[] para =
            {
                new SqlParameter("@INVOICEBATCHNAME", SqlDbType.VarChar,  50),
                new SqlParameter("@ISUSING",          SqlDbType.VarChar,  10),
                new SqlParameter("@INVOICEBATCHMEMO", SqlDbType.VarChar, 200),
                new SqlParameter("@INVOICEBATCHID",   SqlDbType.Int)
            };
            para[0].Value = MODELINVOICEBATCH.INVOICEBATCHNAME;
            para[1].Value = MODELINVOICEBATCH.ISUSING;
            para[2].Value = MODELINVOICEBATCH.INVOICEBATCHMEMO;
            para[3].Value = MODELINVOICEBATCH.INVOICEBATCHID;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool Insert(MODELINVOICEBATCH MODELINVOICEBATCH)
        {
            StringBuilder str = new StringBuilder();

            str.Append("INSERT INTO INVOICEBATCH(INVOICEBATCHNAME,INVOICEBATCHMEMO) ");
            str.Append("VALUES(@INVOICEBATCHNAME,@INVOICEBATCHMEMO)");
            SqlParameter[] para =
            {
                new SqlParameter("@INVOICEBATCHNAME", SqlDbType.VarChar, 50),
                new SqlParameter("@INVOICEBATCHMEMO", SqlDbType.VarChar, 200)
            };
            para[0].Value = MODELINVOICEBATCH.INVOICEBATCHNAME;
            para[1].Value = MODELINVOICEBATCH.INVOICEBATCHMEMO;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtBatchName.Text.Trim() == "")
                {
                    txtBatchName.Focus();
                    mes.Show("请输入发票批次!");
                    return;
                }

                MODELINVOICEBATCH MODELINVOICEBATCH = new MODELINVOICEBATCH();
                MODELINVOICEBATCH.INVOICEBATCHNAME = txtBatchName.Text;
                if (chkIsUsing.Checked)
                {
                    MODELINVOICEBATCH.ISUSING = "1";
                }
                else
                {
                    MODELINVOICEBATCH.ISUSING = "0";
                }
                MODELINVOICEBATCH.INVOICEBATCHMEMO = txtMemo.Text;
                if (txtID.Text == "")
                {
                    //新增发票记录
                    //查询发票批次是否已经存在
                    DataTable dt = BLLINVOICEBATCH.Query(" AND INVOICEBATCHNAME='" + txtBatchName.Text + "'");
                    if (dt.Rows.Count > 0)
                    {
                        txtBatchName.Focus();
                        mes.Show("名称为'" + txtBatchName.Text + "'的发票批次已经存在!");
                        return;
                    }
                    if (BLLINVOICEBATCH.Insert(MODELINVOICEBATCH))
                    {
                        toolSearch_Click(null, null);
                        if (dgList.Rows.Count > 0)
                        {
                            dgList.ClearSelection();
                            dgList.CurrentCell = dgList.Rows[dgList.Rows.Count - 1].Cells["INVOICEBATCHNAME"];
                            dgList_CellClick(null, new DataGridViewCellEventArgs(2, dgList.Rows.Count - 1));
                        }
                    }
                    else
                    {
                        mes.Show("新增发票批次记录失败,请重新操作!");
                        return;
                    }
                }
                else
                {
                    MODELINVOICEBATCH.INVOICEBATCHID = txtID.Text;
                    if (BLLINVOICEBATCH.Update(MODELINVOICEBATCH))
                    {
                        if (dgList.CurrentRow != null)
                        {
                            dgList.CurrentRow.Cells["INVOICEBATCHNAME"].Value = MODELINVOICEBATCH.INVOICEBATCHNAME;
                            dgList.CurrentRow.Cells["ISUSING"].Value          = MODELINVOICEBATCH.ISUSING;
                            dgList.CurrentRow.Cells["INVOICEBATCHMEMO"].Value = MODELINVOICEBATCH.INVOICEBATCHMEMO;
                        }
                    }
                    else
                    {
                        mes.Show("修改发票批次记录失败,请重新查询后再修改!");
                        return;
                    }
                }

                dgList.Enabled     = true;
                toolAdd.Text       = "新增";
                toolSearch.Enabled = true;
                toolDelete.Enabled = true;
                isADD = false;

                if (frm != null)
                {
                    frm.isModify = true;
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.ToString(), MsgType.Error);
                mes.Show(ex.Message);
            }
        }