public bool Delete(EngineeringRequisitionDetailProvider provider)
        {
            bool IsDelete = false;

            try
            {
                SqlCommand command = new SqlCommand();
                this.ConnectionOpen();
                command.Connection = Connection;
                this.BeginTransaction(true);
                command.Transaction = this.Transaction;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = StoredProcedureNames.RequisitionDetailSet;
                command.Parameters.Add("@ID", SqlDbType.Int).Value     = provider.ID;
                command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Delete;
                command.ExecuteNonQuery();
                this.CommitTransaction();
                this.ConnectionClosed();
                IsDelete = true;
            }
            catch (Exception exp)
            {
                this.RollbackTransaction();
                throw new Exception(exp.Message);
            }
            finally
            {
                this.ConnectionClosed();
            }
            return(IsDelete);
        }
        public bool Update(EngineeringRequisitionDetailProvider provider)
        {
            bool IsUpdate = false;

            try
            {
                SqlCommand command = null;
                command = ProcedureFunction(provider);
                command.Parameters.Add("@ID", SqlDbType.Int).Value           = provider.ID;
                command.Parameters.Add("@UpdateUserID", SqlDbType.Int).Value = provider.UpdateUserID;
                command.Parameters.Add("@Option", SqlDbType.Int).Value       = DBConstants.DataModificationOption.Update;
                command.ExecuteNonQuery();
                this.CommitTransaction();
                this.ConnectionClosed();
                IsUpdate = true;
            }
            catch (Exception exp)
            {
                this.RollbackTransaction();
                throw new Exception(exp.Message);
            }
            finally
            {
                this.ConnectionClosed();
            }
            return(IsUpdate);
        }
Пример #3
0
        private List <EngineeringRequisitionDetailProvider> requisitionDetailEntityList()
        {
            List <EngineeringRequisitionDetailProvider> requisitionDetailProviderList = new List <EngineeringRequisitionDetailProvider>();

            foreach (GridViewRow row in gvPurchaseForLSE.Rows)
            {
                EngineeringRequisitionDetailProvider obj = new EngineeringRequisitionDetailProvider();

                HiddenField hfRowProductID      = (HiddenField)row.FindControl("hfProductID");
                TextBox     txtRequiredQuantity = (TextBox)row.FindControl("txtRequiredQuantity");
                TextBox     txtRemarks          = (TextBox)row.FindControl("txtRemarks");
                Label       lblTotalAmount      = (Label)row.FindControl("lblTotalAmount");
                ImageButton btnAddOrDelete      = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE");

                Label lblProductName = (Label)row.FindControl("lblProduct");

                TextBox txtSentQuantity = (TextBox)row.FindControl("txtSentQuantity");

                obj.ProductID        = hfRowProductID.Value.Toint();
                obj.RequiredQuantity = txtRequiredQuantity.Text.ToDecimal();
                obj.SentQuantity     = txtSentQuantity.Text.ToDecimal();
                obj.Remarks          = txtRemarks.Text.ToString();
                if (obj.RequiredQuantity <= 0)
                {
                    throw new Exception("Please input required quantity");
                }

                requisitionDetailProviderList.Add(obj);
            }
            return(requisitionDetailProviderList);
        }
        private SqlCommand ProcedureFunction(EngineeringRequisitionDetailProvider provider)
        {
            SqlCommand command = new SqlCommand();

            this.ConnectionOpen();
            command.Connection = Connection;
            this.BeginTransaction(true);
            command.Transaction = this.Transaction;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = StoredProcedureNames.RequisitionDetailSet;
            command.Parameters.Add("@ProductID", SqlDbType.Int).Value        = provider.ProductID;
            command.Parameters.Add("@Rate", SqlDbType.VarChar).Value         = provider.RawProductName;
            command.Parameters.Add("@RateInDollar", SqlDbType.Decimal).Value = provider.RequiredQuantity;
            command.Parameters.Add("@CurrencyRate", SqlDbType.Decimal).Value = provider.SentQuantity;
            command.Parameters.Add("@CurrencyRate", SqlDbType.VarChar).Value = provider.Remarks;
            return(command);
        }