예제 #1
0
        public bool Insert(MODELEXTRACHARGE MODELEXTRACHARGE)
        {
            StringBuilder str = new StringBuilder();

            str.Append("INSERT INTO dbo.extraCharge(extraChargeID,extraChargeName,extraChargeValue,extraChargeState,MEMO) ");
            str.Append("VALUES(@extraChargeID,@extraChargeName,@extraChargeValue,@MEMO)");
            SqlParameter[] para =
            {
                new SqlParameter("@extraChargeID",    SqlDbType.VarChar, 30),
                new SqlParameter("@extraChargeName",  SqlDbType.VarChar, 50),
                new SqlParameter("@extraChargeValue", SqlDbType.Float),
                new SqlParameter("@extraChargeState", SqlDbType.VarChar, 10),
                new SqlParameter("@MEMO",             SqlDbType.VarChar, 200)
            };
            para[0].Value = MODELEXTRACHARGE.extraChargeID;
            para[1].Value = MODELEXTRACHARGE.extraChargeName;
            para[2].Value = MODELEXTRACHARGE.extraChargeValue;
            para[3].Value = MODELEXTRACHARGE.extraChargeState;
            para[4].Value = MODELEXTRACHARGE.MEMO;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() == "")
            {
                mes.Show("费用名称不能为空!");
                txtName.Focus();
                return;
            }
            if (txtFeePrice.Text.Trim() == "")
            {
                txtFeePrice.Text = "0";
            }
            else
            {
                if (!Information.IsNumeric(txtFeePrice.Text.Trim()))
                {
                    mes.Show("费用单价只能为数字!");
                    txtFeePrice.Focus();
                    return;
                }
            }

            MODELEXTRACHARGE MODELEXTRACHARGE = new MODELEXTRACHARGE();

            MODELEXTRACHARGE.extraChargeName  = txtName.Text;
            MODELEXTRACHARGE.extraChargeValue = Convert.ToDecimal(txtFeePrice.Text);
            if (chkIsUsed.Checked)
            {
                MODELEXTRACHARGE.extraChargeState = "1";
            }
            else
            {
                MODELEXTRACHARGE.extraChargeState = "0";
            }
            MODELEXTRACHARGE.MEMO          = txtMemo.Text;
            MODELEXTRACHARGE.extraChargeID = txtID.Text;
            if (BLLEXTRACHARGE.Update(MODELEXTRACHARGE))
            {
                Query();
                dgList.ClearSelection();
                for (int i = 0; i < dgList.Rows.Count; i++)
                {
                    if (dgList.Rows[i].Cells["extraChargeID"].Value != null && dgList.CurrentRow.Cells["extraChargeID"].Value != DBNull.Value)
                    {
                        string strID = dgList.Rows[i].Cells["extraChargeID"].Value.ToString();
                        if (MODELEXTRACHARGE.extraChargeID == strID)
                        {
                            dgList.CurrentCell = dgList.Rows[i].Cells["extraChargeName"];
                            dgList_SelectionChanged(null, null);
                        }
                    }
                }
            }
            else
            {
                mes.Show("修改失败,请重新点击保存按钮!");
                return;
            }
            dgList.Enabled = true;
        }
예제 #3
0
        public bool Update(MODELEXTRACHARGE MODELEXTRACHARGE)
        {
            StringBuilder str = new StringBuilder();

            str.Append("UPDATE extraCharge SET extraChargeName=@extraChargeName,extraChargeValue=@extraChargeValue,extraChargeState=@extraChargeState,MEMO=@MEMO ");
            str.Append("WHERE extraChargeID=@extraChargeID");
            SqlParameter[] para =
            {
                new SqlParameter("@extraChargeName",  SqlDbType.VarChar,  50),
                new SqlParameter("@extraChargeValue", SqlDbType.Float),
                new SqlParameter("@extraChargeState", SqlDbType.VarChar,  10),
                new SqlParameter("@MEMO",             SqlDbType.VarChar, 200),
                new SqlParameter("@extraChargeID",    SqlDbType.VarChar, 30)
            };
            para[0].Value = MODELEXTRACHARGE.extraChargeName;
            para[1].Value = MODELEXTRACHARGE.extraChargeValue;
            para[2].Value = MODELEXTRACHARGE.extraChargeState;
            para[3].Value = MODELEXTRACHARGE.MEMO;
            para[4].Value = MODELEXTRACHARGE.extraChargeID;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }