private Equipment ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var mInfo = new Equipment
                {
                    Name            = dv.Row["EquipmentName"].ToString().Trim(),
                    LicenseStatus   = true,
                    EquipmentTypeId = 1
                };

                var tsc = new EquipmentServices().AddEquipmentCheckDuplicate(mInfo);
                if (tsc > 0)
                {
                    return(mInfo);
                }
                return(null);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
        public ActionResult Equipments()
        {
            var equipmentTypeList = new EquipmentTypeServices().GetAllOrderedEquipmentTypes() ?? new List <EquipmentType>();

            if (!equipmentTypeList.Any())
            {
                return(RedirectToAction("EquipmentTypes", "EquipmentType"));
            }

            var equipmentList = new EquipmentServices().GetAllOrderedEquipments() ?? new List <Equipment>();

            if (!equipmentList.Any())
            {
                ViewBag.Edit  = 1;
                ViewBag.Title = "Equipment Type SetUp";
                return(View(Tuple.Create(equipmentTypeList, new List <Equipment>())));
            }
            equipmentList.ForEach(m =>
            {
                m.EquipmentLicenseStatus = m.LicenseStatus ? "Licensed" : "Unlicensed";
            });

            var txx = Tuple.Create(equipmentTypeList, equipmentList);

            ViewBag.Title = "Manage Equipments";
            return(View(txx));
        }
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         EquipmentServices catService = new EquipmentServices();
         Food f = catService.GetById(id);
         f.Id   = id;
         f.Name = textBox5.Text;
         f.Cost = Convert.ToDouble(textBox4.Text);
         int result = catService.update(f);
         if (result > 0)
         {
             MessageBox.Show("Food updated.");
             UpdateGridView();
         }
         else
         {
             MessageBox.Show("Error");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error!");
     }
 }
        public ActionResult EditEquipment(int id)
        {
            var equipment = new Equipment();

            try
            {
                if (id < 1)
                {
                    equipment.Error     = "Invalid Selection!";
                    equipment.ErrorCode = -1;
                    return(Json(equipment, JsonRequestBehavior.AllowGet));
                }

                var myViewObj = new EquipmentServices().GetEquipment(id);

                if (myViewObj == null || myViewObj.EquipmentId < 1)
                {
                    equipment.Error     = "Equipment  Information could not be retrieved.";
                    equipment.ErrorCode = -1;
                    return(Json(equipment, JsonRequestBehavior.AllowGet));
                }
                Session["_equipment"] = myViewObj;
                myViewObj.ErrorCode   = myViewObj.EquipmentId;
                return(Json(myViewObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                equipment.Error     = "An unknown error was Equipment  Information could not be retrieved.";
                equipment.ErrorCode = -1;
                return(Json(equipment, JsonRequestBehavior.AllowGet));
            }
        }
        private void Customer_Book_Event_Load(object sender, EventArgs e)
        {
            VenueServices catService    = new VenueServices();
            var           list          = catService.GetAllVenues();
            List <string> categoryNames = new List <string>();

            foreach (var item in list)
            {
                categoryNames.Add(item.Name);
            }
            comboBox2.DataSource = categoryNames;

            EquipmentServices eService = new EquipmentServices();
            var           list1        = eService.GetAllFood();
            List <string> foodName     = new List <string>();

            foreach (var item in list1)
            {
                foodName.Add(item.Name);
            }
            checkedListBox1.DataSource = foodName;

            EquipmentService eqService = new EquipmentService();
            var           list2        = eqService.GetAllEquipment();
            List <string> eqName       = new List <string>();

            foreach (var item in list2)
            {
                eqName.Add(item.Name);
            }
            checkedListBox2.DataSource = eqName;
        }
        public ActionResult AddEquipment(Equipment equipment)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (!ModelState.IsValid)
                {
                    equipment.Error     = "Please supply all required fields and try again";
                    equipment.ErrorCode = -1;
                    return(Json(equipment, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(equipment);

                if (wx.Code < 1)
                {
                    equipment.Error     = wx.Error;
                    equipment.ErrorCode = -1;
                    return(Json(equipment, JsonRequestBehavior.AllowGet));
                }

                equipment.EquipmentType = new EquipmentType
                {
                    EquipmentTypeId = equipment.EquipmentTypeId,
                    Name            = equipment.EquipmentType.Name
                };
                equipment.EquipmentLicenseStatus = equipment.LicenseStatus ? "Licensed" : "Unlicensed";
                var k = new EquipmentServices().AddEquipmentCheckDuplicate(equipment);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        equipment.Error     = "Equipment  already exists";
                        equipment.ErrorCode = -3;
                        return(Json(equipment, JsonRequestBehavior.AllowGet));
                    }

                    equipment.Error     = "Process Failed! Please contact the Admin or try again later";
                    equipment.ErrorCode = 0;
                    return(Json(equipment, JsonRequestBehavior.AllowGet));
                }

                equipment.Error       = "Record was added successfully";
                equipment.ErrorCode   = 1;
                equipment.EquipmentId = k;
                return(Json(equipment, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                equipment.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                equipment.ErrorCode = 0;
                return(Json(equipment, JsonRequestBehavior.AllowGet));
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            EquipmentServices catService = new EquipmentServices();

            int result = catService.delete(id);

            if (result > 0)
            {
                MessageBox.Show("Food deleted.");
                UpdateGridView();
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
        public ActionResult Reports()
        {
            var equipmentList = new EquipmentServices().GetAllOrderedEquipments() ?? new List <Equipment>();

            if (!equipmentList.Any())
            {
                ViewBag.Edit  = 1;
                ViewBag.Title = "Equipment List";
                return(View(new List <Equipment>()));
            }
            equipmentList.ForEach(m =>
            {
                m.EquipmentLicenseStatus = m.LicenseStatus ? "Licensed" : "Unlicensed";
            });

            ViewBag.Title = "Equipment List";
            return(View(equipmentList));
        }
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox2.Text == string.Empty || textBox4.Text == string.Empty || comboBox1.Text == string.Empty || checkedListBox1.CheckedItems.Count == 0 || checkedListBox2.CheckedItems.Count == 0)
         {
             MessageBox.Show("Please Fillup All Requirements....");
         }
         else
         {
             totalCost = 0;
             int           g  = Convert.ToInt32(textBox4.Text);
             VenueServices vs = new VenueServices();
             var           x  = vs.GetByName(comboBox2.Text);
             totalCost += (x.Cost);
             EquipmentServices eq = new EquipmentServices();
             foreach (string s in checkedListBox1.CheckedItems)
             {
                 var y = eq.GetByName(s);
                 totalCost += ((y.Cost) * g);
                 food1     += s + " ";
             }
             EquipmentService es = new EquipmentService();
             foreach (string s in checkedListBox2.CheckedItems)
             {
                 var z = es.GetByName(s);
                 totalCost  += (z.Cost);
                 equipment1 += s + " ";
             }
             textBox1.Text = totalCost.ToString();
             InsertInto(comboBox1.Text, comboBox2.Text, dateTimePicker1.Value.ToShortDateString().ToString(), g, p, food1, equipment1, totalCost);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something is Wrong!!!");
     }
 }
 private void buttonbookingstatus_Click(object sender, EventArgs e)
 {
     if (textBox4.Text == string.Empty || textBox5.Text == string.Empty)
     {
         MessageBox.Show("All required must be fillup!");
     }
     else
     {
         EquipmentServices foodService = new EquipmentServices();
         int result = foodService.Insert(new Food()
         {
             Name = textBox5.Text, Cost = Convert.ToDouble(textBox4.Text)
         });
         if (result > 0)
         {
             MessageBox.Show("Food added.");
             UpdateGridView();
         }
         else
         {
             MessageBox.Show("Error");
         }
     }
 }
        private WellCompletion ProcessRecord2(DataRowView dv, ref string msg, int completionTypeId)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var wellName = dv.Row["wellname"].ToString().Replace(" ", "").Replace(",", "").Trim();

                if (string.IsNullOrEmpty(wellName.Trim()))
                {
                    return(null);
                }

                var mInfo = new WellCompletion
                {
                    WellName = wellName,
                };

                var ttcg = new WellServices().GetWellIdByName(wellName);

                if (ttcg < 1)
                {
                    msg = "Well Information could not be processed";
                    return(null);
                }

                mInfo.WellId = ttcg;

                var year = dv.Row["datecompleted(yyyy/MM/dd)"].ToString().Trim();
                if (string.IsNullOrEmpty(year))
                {
                    msg = "Completion Date is empty.";
                    return(null);
                }
                else
                {
                    DateTime outYear;
                    var      yrResult = DateTime.TryParse(year, out outYear);
                    if (!yrResult)
                    {
                        msg = "Completion Date is empty.";
                        return(null);
                    }
                    else
                    {
                        mInfo.DateCompleted = outYear;
                    }
                }

                var completionStatus = dv.Row["isinitialcompletion(YES/NO)"].ToString().Trim();

                if (string.IsNullOrEmpty(completionStatus))
                {
                    msg = "Please indicate if Well Completion is Initial or ortherwise.";
                    return(null);
                }
                else
                {
                    if (completionStatus.Trim().ToLower().Replace(" ", "") == "yes")
                    {
                        mInfo.IsInitial = true;
                    }
                    if (completionStatus.Trim().ToLower().Replace(" ", "") == "no")
                    {
                        mInfo.IsInitial = false;
                    }
                }
                double l1;
                double up1;
                double l2;
                double up2;
                var    lowerInter1 = dv.Row["lower_interval_1"].ToString().Trim();
                if (string.IsNullOrEmpty(lowerInter1))
                {
                    msg = "Please provide lower Interval 1.";
                    return(null);
                }
                else
                {
                    double outLint;
                    var    dtResult = double.TryParse(lowerInter1, out outLint);
                    if (!dtResult && outLint < 1)
                    {
                        msg = "Please provide a valid lower Interval 1.";
                        return(null);
                    }
                    else
                    {
                        l1 = outLint;
                    }
                }

                var upperInter = dv.Row["upper_interval_1"].ToString().Trim();
                if (string.IsNullOrEmpty(upperInter))
                {
                    msg = "Please provide Upper Interval 1.";
                    return(null);
                }
                else
                {
                    double outUpint;
                    var    dtResult = double.TryParse(upperInter, out outUpint);
                    if (!dtResult && outUpint < 1)
                    {
                        msg = "Please provide a valid Upper Interval 1.";
                        return(null);
                    }
                    else
                    {
                        up1 = outUpint;
                    }
                }

                var lowerInter2 = dv.Row["lower_interval_2"].ToString().Trim();
                if (string.IsNullOrEmpty(lowerInter2))
                {
                    msg = "Please provide lower Interval 2.";
                    return(null);
                }
                else
                {
                    double outLint2;
                    var    dtResult = double.TryParse(lowerInter2, out outLint2);
                    if (!dtResult && outLint2 < 1)
                    {
                        msg = "Please provide a valid lower Interval 2.";
                        return(null);
                    }
                    else
                    {
                        l2 = outLint2;
                    }
                }

                var upperInter2 = dv.Row["upper_interval_2"].ToString().Trim();
                if (string.IsNullOrEmpty(upperInter2))
                {
                    msg = "Please provide Upper Interval 2.";
                    return(null);
                }
                else
                {
                    double outUpint2;
                    var    dtResult = double.TryParse(upperInter2, out outUpint2);
                    if (!dtResult && outUpint2 < 1)
                    {
                        msg = "Please provide a valid Upper Interval 2.";
                        return(null);
                    }
                    else
                    {
                        up2 = outUpint2;
                    }
                }


                if (!string.IsNullOrEmpty(dv.Row["equipmentused"].ToString().Trim()))
                {
                    var dfv         = dv.Row["equipmentused"].ToString().Trim();
                    var equipmentId = new EquipmentServices().GetEquipmentId(dfv);
                    if (equipmentId < 1)
                    {
                        msg = "Equipment Information could not be processed";
                        return(null);
                    }

                    mInfo.EquipmentId = equipmentId;
                }
                else
                {
                    msg = "Equipment used empty.";
                    return(null);
                }

                mInfo.WellCompletionTypeId = completionTypeId;

                var vvz = new WellCompletionServices().AddWellCompletionCheckDuplicate3(mInfo);
                if (vvz < 1)
                {
                    msg = "Well Completion Interval for the same Period, Reason, Completion Type and Equipment already exists for this well.";
                    return(null);
                }

                var wellCompInt = new WellCompletionInterval
                {
                    LowerInterval    = l1,
                    WellCompletionId = vvz,
                    UpperInterval    = up1,
                    DateCompleted    = mInfo.DateCompleted.ToString(),
                    LastUpdatedTime  = DateTime.Now.ToString("G")
                };

                var vvzk = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(wellCompInt);
                if (vvzk < 1)
                {
                    msg = "Well Completion Information could not be processed.";
                    return(null);
                }

                var tdd = new WellCompletionInterval
                {
                    LowerInterval    = l2,
                    WellCompletionId = vvz,
                    UpperInterval    = up2,
                    DateCompleted    = mInfo.DateCompleted.ToString(),
                    LastUpdatedTime  = DateTime.Now.ToString("G")
                };

                var vvzk2 = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(tdd);
                if (vvzk2 < 1)
                {
                    new WellCompletionIntervalServices().DeleteWellCompletionIntervalCheckReferences(vvzk);
                    msg = "Well Completion Information could not be processed.";
                    return(null);
                }

                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
        void UpdateGridView()
        {
            EquipmentServices fService = new EquipmentServices();

            dataGridView2.DataSource = fService.GetAllFood();
        }
        private void Food_management_Load(object sender, EventArgs e)
        {
            EquipmentServices fService = new EquipmentServices();

            dataGridView2.DataSource = fService.GetAllFood();
        }
Example #14
0
        private WellWorkover ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var wellName = dv.Row["well_name"].ToString().Replace(" ", "").Replace(",", "").Trim();

                if (string.IsNullOrEmpty(wellName.Trim()))
                {
                    return(null);
                }

                var mInfo = new WellWorkover
                {
                    WellName = wellName,
                };

                var ttcg = new WellServices().GetWellIdByName(wellName);

                if (ttcg < 1)
                {
                    msg = "Well Information could not be processed";
                    return(null);
                }

                mInfo.WellId = ttcg;

                var  year = dv.Row["workover_Completion_year(yyyy)"].ToString().Trim();
                long outYear;
                var  yrResult = long.TryParse(year, out outYear);
                if (!yrResult && outYear < 1)
                {
                    msg = "Invalid Workover Completion Year.";
                    return(null);
                }
                else
                {
                    mInfo.Year = outYear;
                }
                //workover_Completion_year(yyyy)

                var month = dv.Row["workover_Completion_month(MM)"].ToString().Trim();
                int outMonth;
                var mnResult = int.TryParse(month, out outMonth);
                if (!mnResult && outMonth < 1)
                {
                    msg = "Invalid Workover Completion Month.";
                    return(null);
                }
                else
                {
                    mInfo.Month = outMonth;
                }


                mInfo.DateCompleted = outYear + "/" + outMonth + "/01";

                if (!string.IsNullOrEmpty(dv.Row["equipment_used"].ToString().Trim()))
                {
                    var dfv         = dv.Row["equipment_used"].ToString().Trim();
                    var equipmentId = new EquipmentServices().GetEquipmentId(dfv);
                    if (equipmentId < 1)
                    {
                        msg = "Equipment Information could not be processed";
                        return(null);
                    }

                    mInfo.EquipmentId = equipmentId;
                }
                else
                {
                    msg = "Equipment used is empty.";
                    return(null);
                }

                var reason = dv.Row["workover_reason"].ToString().Trim();
                if (!string.IsNullOrEmpty(reason))
                {
                    var dfv      = reason;
                    var reasonId = new WellWorkOverReasonServices().GetWellWorkOverReasonIdByName(dfv);
                    if (reasonId < 1)
                    {
                        msg = "Workover Reason Information could not be processed";
                        return(null);
                    }
                    mInfo.WellWorkOverReasonId = reasonId;
                }
                else
                {
                    msg = "Workover Reason is empty";
                    return(null);
                }
                var status = new WellWorkoverServices().AddWellWorkoverCheckDuplicates(mInfo, mInfo.WellId, mInfo.WellWorkOverReasonId, mInfo.Month, mInfo.Year);
                if (status < 1)
                {
                    if (status == -3)
                    {
                        msg = "Well workover for the same Period, Reason and Equipment already exists for this well.";
                        return(null);
                    }

                    msg = "An error encountered during upload.";
                    return(null);
                }

                mInfo.WellWorkOverId = status;
                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }