protected void grdResins_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // Normal controls
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate))))
            {
                int resinId = Int32.Parse(((Label)e.Row.FindControl("lblResinId")).Text);

                // Validate buttons
                if ((resinId == 1) || (resinId == 2) || (resinId == 3))
                {
                    ((ImageButton)e.Row.FindControl("ibtnEdit")).Visible = false;
                    ((ImageButton)e.Row.FindControl("ibtnDelete")).Visible = false;
                }
            }

            // Edit controls
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int resinId = Int32.Parse(((Label)e.Row.FindControl("lblResinIdEdit")).Text);

                FlResinsAddGateway flResinsAddGatewayForGrid = new FlResinsAddGateway(flResinsAddTDS);

                if (flResinsAddGatewayForGrid.Table.Rows.Count > 0)
                {
                    string applyCatalyst = flResinsAddGatewayForGrid.GetApplyCatalystTo(resinId);
                    ((DropDownList)e.Row.FindControl("ddlApplyCatalystToEdit")).SelectedValue = applyCatalyst;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Save all resins to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>        
        public void Save(int companyId)
        {
            FlResinsAddTDS flResinsAddChanges = (FlResinsAddTDS)Data.GetChanges();

            if (flResinsAddChanges.FlResinsAdd.Rows.Count > 0)
            {
                FlResinsAddGateway flResinsAddGateway = new FlResinsAddGateway(flResinsAddChanges);

                foreach (FlResinsAddTDS.FlResinsAddRow row in (FlResinsAddTDS.FlResinsAddDataTable)flResinsAddChanges.FlResinsAdd)
                {
                    // Insert new resins
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        WorkFullLengthLiningResins workFullLengthLiningResins = new WorkFullLengthLiningResins(null);
                        workFullLengthLiningResins.InsertDirect(row.ResinID, row.ResinMake, row.ResinType, row.ResinNumber, row.LbUsg, row.LbDrums, row.ActiveResin, row.ApplyCatalystTo, row.Filter, row.Deleted, row.COMPANY_ID);
                    }

                     //Update resins
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int resinId = row.ResinID;
                        bool originalDeleted = false;
                        int originalCompanyId = companyId;

                        // original values
                        string originalResinMake = flResinsAddGateway.GetResinMakeOriginal(resinId);
                        string originalResinType = flResinsAddGateway.GetResinTypeOriginal(resinId);
                        string originalResinNumber = flResinsAddGateway.GetResinNumberOriginal(resinId);
                        decimal originalLbUsg = flResinsAddGateway.GetLbUsgOriginal(resinId);
                        int originalLbDrum = flResinsAddGateway.GetLbDrumsOriginal(resinId);
                        decimal originalActiveResin = flResinsAddGateway.GetActiveResinOriginal(resinId);
                        string originalApplyCatalystToNumber = flResinsAddGateway.GetApplyCatalystToOriginal(resinId);
                        decimal originalFilter = flResinsAddGateway.GetFilterOriginal(resinId);

                        // new values
                        string newResinMake = flResinsAddGateway.GetResinMake(resinId);
                        string newResinType = flResinsAddGateway.GetResinType(resinId);
                        string newResinNumber = flResinsAddGateway.GetResinNumber(resinId);
                        decimal newLbUsg = flResinsAddGateway.GetLbUsg(resinId);
                        int newLbDrum = flResinsAddGateway.GetLbDrums(resinId);
                        decimal newActiveResin = flResinsAddGateway.GetActiveResin(resinId);
                        string newApplyCatalystToNumber = flResinsAddGateway.GetApplyCatalystTo(resinId);
                        decimal newFilter = flResinsAddGateway.GetFilter(resinId);

                        WorkFullLengthLiningResins workFullLengthLiningResins = new WorkFullLengthLiningResins(null);
                        workFullLengthLiningResins.UpdateDirect(resinId, originalResinMake, originalResinType, originalResinNumber, originalLbUsg, originalLbDrum, originalActiveResin, originalApplyCatalystToNumber, originalFilter, originalDeleted, originalCompanyId, resinId, newResinMake, newResinType, newResinNumber, newLbUsg, newLbDrum, newActiveResin, newApplyCatalystToNumber, newFilter, originalDeleted, originalCompanyId);
                    }

                    // Deleted resins
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        WorkFullLengthLiningResins workFullLengthLiningResins = new WorkFullLengthLiningResins(null);
                        workFullLengthLiningResins.DeleteDirect(row.ResinID, row.COMPANY_ID);
                    }
                }
            }
        }