Exemple #1
0
        public static bool Insert(SubSectionInfo objSubSectionInfo)
        {
            ISalesPOSDBManager dbManager = new SalesPOSDBManager();
            Boolean            chk       = false;

            try
            {
                dbManager.Open();
                IDbDataParameter[] param = SalesPOSDBManagerFactory.GetParameters(dbManager.ProviderType, 6);

                param[0] = dbManager.getparam("@SubSectionName", objSubSectionInfo.SubSectionName.ToString());
                param[1] = dbManager.getparam("@SectionID", objSubSectionInfo.SectionID.ToString());
                param[2] = dbManager.getparam("@ActivityID", objSubSectionInfo.ActivityID.ToString());

                param[3] = dbManager.getparam("@CreatedDate", objSubSectionInfo.CreatedDate);
                param[4] = dbManager.getparam("@CreatedBy", objSubSectionInfo.CreatedBy.ToString());
                param[5] = dbManager.getparam("@IsDeleted", false);

                IDbCommand cmd = dbManager.getCommand(CommandType.StoredProcedure, "USP_SubSectionInfo_Add", param);

                chk = dbManager.ExecuteQuery(cmd);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                dbManager.Dispose();
            }
            return(chk);
        }
Exemple #2
0
        internal SectionInfo(Type sectionType)
        {
            SectionType = sectionType;

            var attribute = sectionType.GetCustomAttribute <SectionAttribute>();

            if (attribute == null)
            {
                throw new ArgumentException("Section type is missing section attribute", nameof(sectionType));
            }

            Signature = attribute.Signature;

            for (var type = sectionType.BaseType; type != null; type = type.BaseType)
            {
                var genericTypeDefinition = type.GetGenericTypeDefinition();
                if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Section <>))
                {
                    DataType = type.GetGenericArguments()[0];
                    break;
                }
            }

            if (DataType == null)
            {
                DataType = attribute.DataType;
            }

            IsBinaryFileType = typeof(IBinaryFile).IsAssignableFrom(DataType);

            foreach (var propertyInfo in sectionType.GetProperties())
            {
                var subSectionAttribute = propertyInfo.GetCustomAttribute <SubSectionAttribute>();
                if (subSectionAttribute == null)
                {
                    continue;
                }

                var subSectionInfo = new SubSectionInfo(propertyInfo);
                mSubSectionInfos.Add(subSectionInfo.SectionInfo, subSectionInfo);
            }
        }
Exemple #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (isValid())
            {
                if (!this._isNew)
                {
                    if (_SelctedSubSectionInfoId > 0)
                    {
                        //update here
                        bool chk = true;

                        SubSectionInfo objSubSectionInfo = new SubSectionInfo();
                        objSubSectionInfo.SubSectionID   = this._SelctedSubSectionInfoId;
                        objSubSectionInfo.SubSectionName = this.txtSubSectionName.Text.Trim();
                        objSubSectionInfo.SectionID      = Convert.ToInt64(this.cmbSectionName.SelectedValue);
                        objSubSectionInfo.ActivityID     = Convert.ToInt64(this.cmbActivity.SelectedValue);

                        objSubSectionInfo.UpdatedBy   = 1;
                        objSubSectionInfo.UpdatedDate = DateTime.Now;

                        chk = bllSubSectionInfo.Update(objSubSectionInfo);
                        if (chk)
                        {
                            LoadGrid();
                            //show success message here
                            XtraMessageBox.Show("Successfully updated the record");
                            ClearFields();
                            this._isNew = true;
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("No data found for update.");
                    }
                }
                else
                {
                    bool chk = true;
                    //insert validation method

                    //insert here
                    SubSectionInfo objSubSectionInfo = new SubSectionInfo();
                    objSubSectionInfo.SubSectionName = this.txtSubSectionName.Text.Trim();
                    objSubSectionInfo.SectionID      = Convert.ToInt64(this.cmbSectionName.SelectedValue);
                    objSubSectionInfo.ActivityID     = Convert.ToInt64(this.cmbActivity.SelectedValue);

                    objSubSectionInfo.CreatedBy   = 1;
                    objSubSectionInfo.CreatedDate = DateTime.Now;

                    chk = bllSubSectionInfo.Insert(objSubSectionInfo);
                    if (chk)
                    {
                        LoadGrid();
                        //show success message here

                        ClearFields();
                        this._isNew = true;
                    }
                }
                if (this.dgvSubSectionList.Rows.Count > 0)
                {
                    this.dgvSubSectionList.Rows[0].Selected = false;
                }
            }
        }