Пример #1
0
        private bool InsertWorkload(KeyPerformanceIndex kpi, DbConnection con, DbTransaction trans)
        {
            bool retval = true;

            try
            {
                for (int i = 0; i < dgv03.RowCount; i++)
                {
                    if (String.IsNullOrEmpty(dgv03.Rows[i].Cells[1].Value.ToString()))
                    {
                        kpi.KPIID        = LAST_KPI_ID;
                        kpi.KPMID        = "003";
                        kpi.ManagerID    = dgv03.Rows[i].Cells[8].Value.ToString();
                        kpi.Description  = dgv03.Rows[i].Cells[2].Value.ToString();
                        kpi.Prefix       = dgv03.Rows[i].Cells[3].Value.ToString();
                        kpi.EstimateYear = dgv03.Rows[i].Cells[10].Value.ToString();
                        //double x = Convert.ToDouble(dgv01.Rows[i].Cells[5].Value);

                        kpi.EstimateValue = Convert.ToDouble(dgv03.Rows[i].Cells[5].Value);
                        kpi.Unit          = dgv03.Rows[i].Cells[6].Value.ToString();

                        kpi.ServicePlanID = dgv01.Rows[i].Cells[11].Value.ToString();

                        kpi.InsertKPI(db, con, trans);
                        kpi.InsertKPIEstimate(db, con, trans);

                        LAST_KPI_ID++;
                    }
                }
            }
            catch (Exception ex)
            {
                retval = false;
            }
            return(retval);
        }
Пример #2
0
        private bool SaveDataToDatabase(string kpm_id, DataGridView dgv, DbConnection con, DbTransaction trans)
        {
            bool retval = true;
            KeyPerformanceIndex kpi;

            LAST_KPI_ID = KeyPerformanceIndex.getNextKPIIndex();
            int  mKPIId;
            bool mNewFlag = false;

            try
            {
                for (int i = 0; i < dgv.RowCount; i++)
                {
                    if (!MyGridUtils.IsColumnDataChanged(dgv.Rows[i],
                                                         new List <String>()
                    {
                        "Description", "PrefixID", "Value", "UnitID", "ManagerID", "SP_ID", "STATUS"
                    },
                                                         new List <String>()
                    {
                        "BDescription", "BPrefixID", "BValue", "BUnitID", "BManagerID", "BSP_ID", "BSTATUS"
                    }))
                    {
                        continue;
                    }
                    //---- Check for KPI Index in the Grid--
                    //--------- If Empty or Null New KPI otherwise Edit
                    if (String.IsNullOrEmpty(dgv.Rows[i].Cells["ID"].Value.ToString()))
                    {
                        mKPIId = LAST_KPI_ID;
                        LAST_KPI_ID++;
                        mNewFlag = true;
                    }
                    else
                    {
                        mKPIId   = int.Parse(dgv.Rows[i].Cells["ID"].Value.ToString());
                        mNewFlag = false;
                    }

                    kpi               = new KeyPerformanceIndex();
                    kpi.KPIID         = mKPIId;
                    kpi.KPMID         = kpm_id;
                    kpi.ManagerID     = dgv.Rows[i].Cells["ManagerID"].Value.ToString();
                    kpi.Description   = dgv.Rows[i].Cells["Description"].Value.ToString();
                    kpi.Prefix        = dgv.Rows[i].Cells["PrefixID"].Value.ToString();
                    kpi.EstimateYear  = dgv.Rows[i].Cells["Est.Year"].Value.ToString();
                    kpi.EstimateValue = Convert.ToDouble(dgv.Rows[i].Cells["Value"].Value);
                    kpi.Unit          = dgv.Rows[i].Cells["UnitID"].Value.ToString();
                    kpi.ServicePlanID = dgv.Rows[i].Cells["SP_ID"].Value == null ? "000" : dgv.Rows[i].Cells["SP_ID"].Value.ToString();
                    kpi.Status        = ((dgv.Rows[i].Cells["STATUS"].Value.ToString().ToUpper() == "TRUE") ? true : false);

                    if (mNewFlag)
                    {
                        kpi.InsertKPI(db, con, trans);
                        kpi.InsertKPIEstimate(db, con, trans);
                    }
                    else
                    {
                        kpi.UpdateKPI(db, con, trans);
                        kpi.UpdateKPIEstimate(db, con, trans);
                    }
                }
            } catch (Exception ex)
            {
                retval = false;
            }
            return(retval);
        }