Пример #1
0
    private void SetData(MemberTypeData data)
    {
        this.txtLOID.Text = data.LOID.ToString();
        this.txtCode.Text = data.CODE.Trim();
        this.chkActive.Checked = (data.ACTIVE == Constz.ActiveStatus.Active);
        this.txtName.Text = data.NAME.Trim();

        SetGrvItem();
    }
Пример #2
0
 private MemberTypeData GetData()
 {
     MemberTypeData data = new MemberTypeData();
     data.ACTIVE = (this.chkActive.Checked ? Constz.ActiveStatus.Active : Constz.ActiveStatus.InActive);
     data.CODE = this.txtCode.Text.Trim();
     data.LOID = Convert.ToDouble(this.txtLOID.Text == "" ? "0" : this.txtLOID.Text);
     data.NAME = this.txtName.Text.Trim();
     data.ITEM = ItemObj.GetItemList();
     return data;
 }
Пример #3
0
 public MemberTypeData GetData(double loid)
 {
     MemberTypeData data = new MemberTypeData();
     if (DALObj.GetDataByLOID(loid, null))
     {
         data.ACTIVE = DALObj.ACTIVE;
         data.CODE = DALObj.CODE;
         data.LOID = DALObj.LOID;
         data.NAME = DALObj.NAME;
         data.DISCOUNT = DALObj.DISCOUNT;
         data.LOWERPRICE = DALObj.LOWERPRICE;
         data.DESCRIPTION = DALObj.DESCRIPTION;
     }
     return data;
 }
Пример #4
0
 private bool VeridateData(MemberTypeData data)
 {
     bool ret = true;
     if (data.CODE.Trim() == "")
     {
         _error = "¡ÃسÒÃкØÃËÑÊ»ÃÐàÀ·ÅÙ¡¤éÒ";
         ret = false;
     }
     else if (data.NAME.Trim() == "")
     {
         _error = "¡ÃسÒÃкت×èÍ»ÃÐàÀ·ÅÙ¡¤éÒ";
         ret = false;
     }
     return ret;
 }
Пример #5
0
        public bool UpdateData(string userID, MemberTypeData data)
        {
            bool ret = true;
            if (VeridateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    DALObj.GetDataByLOID(data.LOID, obj.zTrans);
                    DALObj.LOID = data.LOID;
                    DALObj.NAME = data.NAME.Trim();
                    DALObj.DESCRIPTION = data.DESCRIPTION.Trim();
                    DALObj.ACTIVE = data.ACTIVE.Trim();
                    DALObj.CODE = data.CODE.Trim();
                    DALObj.DISCOUNT = data.DISCOUNT;
                    DALObj.LOWERPRICE = data.LOWERPRICE;

                    int check = Convert.ToInt32(OracleDB.ExecSingleCmd("SELECT COUNT(*) FROM MEMBERTYPE WHERE NAME ='" + data.NAME.Trim() + "' AND LOID != " + data.LOID));
                    if (check > 0)
                    {
                        ret = false;
                        _error = "»ÃÐàÀ·ÅÙ¡¤éÒ«éÓ";
                    }
                    else
                    {
                        DALItemObj.DeleteDataByMemberType(data.LOID, obj.zTrans);

                        if (DALObj.OnDB)
                            ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        else
                            ret = DALObj.InsertCurrentData(userID, obj.zTrans);
                        _LOID = DALObj.LOID;
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                        for (int i = 0; i < data.ITEM.Count; ++i)
                        {
                            DiscountStepData itemData = (DiscountStepData)data.ITEM[i];
                            DALItemObj.OnDB = false;
                            DALItemObj.MEMBERTYPE = DALObj.LOID;
                            DALItemObj.LOWERPRICE = itemData.LOWERPRICE;
                            DALItemObj.DISCOUNT = itemData.DISCOUNT;
                            ret = DALItemObj.InsertCurrentData(userID, obj.zTrans);
                            if (!ret) throw new ApplicationException(DALItemObj.ErrorMessage);
                        }

                        obj.zTrans.Commit();
                        obj.CloseConnection();
                    }
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    _error = ex.Message;
                }
            }
            else
                ret = false;
            return ret;
        }