private static tbl_OperatorInformation GetAverageCost(string prefix, int type) { CRUDOperation cRUDOperation = new CRUDOperation(); tbl_OperatorInformation operatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(prefix, type, (int)OperatorChanelType.Message); return(operatorInformation); }
public ActionResult Create(OperatorInformationVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_OperatorInformation item = new tbl_OperatorInformation() { OperatorType_EVID = viewModel.OperatorTypeEVID, Name = viewModel.Name, OperatorChanelType_EVID = viewModel.OperatorChanelTypeEVID, InOutType_EVID = viewModel.InOutTypeEVID, Price = viewModel.Price, Point = viewModel.Point, InsertDate = DateTime.Now, InsertUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_OperatorInformation operatorInformationControl = dataOperations.ControlOperatorInformation(item); if (operatorInformationControl != null) { TempData["success"] = "notOk"; TempData["message"] = "Eyni parametrelerə sahib məlumat sistemdə mövcudur"; return(RedirectToAction("Index")); } else { tbl_OperatorInformation dbItem = dataOperations.AddOperatorInformation(item); if (dbItem != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla əlavə olundu"; return(RedirectToAction("Index")); } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar əlavə olunarkən xəta baş verdi"; return(RedirectToAction("Index")); } } } } throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { viewModel = poulateDropDownList(viewModel); return(View(viewModel)); } }
public ActionResult Edit(OperatorInformationVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_OperatorInformation item = new tbl_OperatorInformation() { ID = viewModel.ID, OperatorType_EVID = viewModel.OperatorTypeEVID, Name = viewModel.Name, OperatorChanelType_EVID = viewModel.OperatorChanelTypeEVID, InOutType_EVID = viewModel.InOutTypeEVID, Price = viewModel.Price, Point = viewModel.Point, UpdateDate = DateTime.Now, UpdateUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_OperatorInformation dbItem = dataOperations.UpdateOperatorInformation(item); if (dbItem != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla dəyişdirildi"; return(RedirectToAction("Index")); } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar dəyişdirilərkən xəta baş verdi"; return(RedirectToAction("Index")); } } } throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { viewModel = poulateDropDownList(viewModel); return(View(viewModel)); } }
public ActionResult Edit(int id) { OperatorInformationVM viewModel = new OperatorInformationVM(); CRUDOperation dataOperations = new CRUDOperation(); tbl_OperatorInformation tblItem = dataOperations.GetOperatorInformationById(id); tbl_EnumValue enumValue = dataOperations.GetEnumValueById((int)tblItem.OperatorChanelType_EVID); viewModel.EnumCategoryID = enumValue.EnumCategoryID; viewModel = poulateDropDownList(viewModel); viewModel.ID = id; viewModel.OperatorTypeEVID = tblItem.OperatorType_EVID == null?0:(int)tblItem.OperatorType_EVID; viewModel.Name = tblItem.Name; viewModel.OperatorChanelTypeEVID = tblItem.OperatorChanelType_EVID == null ? 0 : (int)tblItem.OperatorChanelType_EVID; viewModel.InOutTypeEVID = tblItem.InOutType_EVID == null ? 0 : (int)tblItem.InOutType_EVID; viewModel.Price = tblItem.Price == null?0:(decimal)tblItem.Price; viewModel.Point = tblItem.Point == null ? 0 : (decimal)tblItem.Point; return(View(viewModel)); }
public void AddCALLReportDetail(Int64 userID, string phoneNumer, tbl_CALLDetail detailItem) { CRUDOperation cRUDOperation = new CRUDOperation(); int _outCallCountSame = 0, _outCallCountOther = 0, _outCallForeignCount = 0, _inCallCount = 0, _inCallForeignCount = 0, _outMissedCallCount = 0, _inMissedCallCount = 0; decimal _outCallSecondSame = 0, _outCallMinuteSame = 0, _outCallSecondOther = 0, _outCallMinuteOther = 0; decimal _outCallForeignSecond = 0, _outCallForeignMinute = 0; decimal _inCallSecond = 0, _inCallMinute = 0, _inCallForeignSecond = 0, _inCallForeignMinute = 0; tbl_OperatorInformation _OperatorInformation = new tbl_OperatorInformation(); decimal pointValue = 0; decimal priceValue = 0; int month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0; int year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0; try { if (detailItem.InOutType == 1) { if (detailItem.IsForeign == 0 && detailItem.Duration > 0) { bool IsSame = NumberHelper.ControlSameOrOther(phoneNumer, detailItem.PhonePrefix); if (IsSame) { _outCallCountSame = 1; _outCallSecondSame = (decimal)detailItem.Duration; _outCallMinuteSame = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutSameMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outCallMinuteSame * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outCallMinuteSame * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else { _outCallCountOther = 1; _outCallSecondOther = (decimal)detailItem.Duration; _outCallMinuteOther = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutOtherMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outCallMinuteOther * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outCallMinuteOther * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } } else if (detailItem.IsForeign == 1 && detailItem.Duration > 0) { _outCallForeignCount = 1; _outCallForeignSecond = (decimal)detailItem.Duration; _outCallForeignMinute = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutForeignMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outCallForeignMinute * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outCallForeignMinute * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else if (detailItem.Duration == 0) { _outMissedCallCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.OutMissedCount, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _outMissedCallCount * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _outMissedCallCount * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } } else { if (detailItem.IsForeign == 0 && detailItem.Duration > 0) { _inCallCount = 1; _inCallSecond = (decimal)detailItem.Duration; _inCallMinute = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.INMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _inCallMinute * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _inCallMinute * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else if (detailItem.IsForeign == 1 && detailItem.Duration > 0) { _inCallForeignCount = 1; _inCallForeignSecond = (decimal)detailItem.Duration; _inCallForeignMinute = Math.Ceiling(((decimal)detailItem.Duration / 60)); _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)CALLOperatorInformation.INForeignMinute, (int)OperatorChanelType.Call); if (_OperatorInformation != null) { pointValue = _inCallForeignMinute * (_OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point); priceValue = _inCallForeignMinute * (_OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.CALL); } } else if (detailItem.Duration == 0) { _inMissedCallCount = 1; } } tbl_CALLReport callReport = new tbl_CALLReport() { CALLDetailID = detailItem.ID, CALLModelID = detailItem.CALLModelID, UserID = userID, Month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0, Year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0, OutCallCountSame = _outCallCountSame, OutCallSecondSame = _outCallSecondSame, OutCallMinuteSame = _outCallMinuteSame, OutCallCountOther = _outCallCountOther, OutCallSecondOther = _outCallSecondOther, OutCallMinuteOther = _outCallMinuteOther, InCallCount = _inCallCount, InCallSecond = _inCallSecond, InCallMinute = _inCallMinute, OutMissedCallCount = _outMissedCallCount, InMissedCallCount = _inMissedCallCount, OutCallForeignCount = _outCallForeignCount, OutCallForeignSecond = _outCallForeignSecond, OutCallForeignMinute = _outCallForeignMinute, InCallForeignCount = _inCallForeignCount, InCallForeignSecond = _inCallForeignSecond, InCallForeignMinute = _inCallForeignMinute, }; cRUDOperation.AddCALLReport(callReport); } catch (Exception ex) { } }
public void AddSMSReportDetail(Int64 userID, string phoneNumer, tbl_SMSDetail detailItem, tbl_SMSSenderInfo smsSenderInfo) { CRUDOperation cRUDOperation = new CRUDOperation(); int _outMsjCountSame = 0, _outMsjCountOther = 0, _outMsjForeignCount = 0, _outMsjRoamingCount = 0; int _inMsjCount = 0, _inMsjForeignCount = 0; tbl_OperatorInformation _OperatorInformation = new tbl_OperatorInformation(); decimal pointValue = 0; decimal priceValue = 0; int month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0; int year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0; try { if (detailItem.IsShortMessage == 0) { if (detailItem.InOutType == 1) { if (detailItem.IsForeign == 0 || detailItem.IsForeign == null) { bool IsSame = NumberHelper.ControlSameOrOther(phoneNumer, detailItem.PhonePrefix); if (IsSame) { _outMsjCountSame = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutSameCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } else { _outMsjCountOther = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutOtherCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } } else if (detailItem.IsForeign == 1) { _outMsjForeignCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutSameCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } } else { if (detailItem.IsForeign == 0 || detailItem.IsForeign == null) { _inMsjCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.INCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } else if (detailItem.IsForeign == 1) { _inMsjForeignCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.INCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } } tbl_SMSReport smsReport = new tbl_SMSReport() { SMSModelID = detailItem.SMSModelID, SMSDetailID = detailItem.ID, UserID = userID, Month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0, Year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0, OutMsjCountSame = _outMsjCountSame, OutMsjCountOther = _outMsjCountOther, OutMsjForeignCount = _outMsjForeignCount, InMsjCount = _inMsjCount, InMsjForeignCount = _inMsjForeignCount, }; cRUDOperation.AddSMSReport(smsReport); } else if (detailItem.IsShortMessage == 1) { if (smsSenderInfo != null) { pointValue = 1 * (smsSenderInfo.Point == null ? 0 : (decimal)smsSenderInfo.Point); priceValue = 1 * (smsSenderInfo.Price == null ? 0 : (decimal)smsSenderInfo.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } if (detailItem.IsParse == 1) { if (detailItem.SenderName == "Azericard") { tbl_SMSReportShort smsRepotShort = ParseAzeriCard(detailItem, userID); //Mebleg:-30.00 AZN if (smsRepotShort != null) { cRUDOperation.AddSMSReportShort(smsRepotShort); decimal priceAzeriCardValue = 0; priceAzeriCardValue = smsRepotShort.Amount; if (smsRepotShort.IsExpense == 1) { if (smsRepotShort.Currency == "AZN") { AddUserPointAndPrice(userID, month, year, 0, priceAzeriCardValue, (int)ChanelType.AzeriCard); AddUserExpenseAbility(userID, "Azericard", "Xərc", month, year, priceAzeriCardValue, (int)ChanelType.AzeriCard); } } else { AddUserIncomeAbility(userID, true, "Azericard", "Gəlir", month, year, priceAzeriCardValue, (int)ChanelType.AzeriCard); } } } if (detailItem.SenderName.ToLower() == "bakcell") { tbl_SMSReportShort smsRepotShort = ParseBakcell(detailItem, userID); //Mebleg:-30.00 AZN if (smsRepotShort != null) { cRUDOperation.AddSMSReportShort(smsRepotShort); if (smsRepotShort.IsExpense == 1) { AddUserPointAndPrice(userID, month, year, 0, smsRepotShort.Amount, (int)ChanelType.Bakcell); AddUserExpenseAbility(userID, "Bakcell", "Kontur", month, year, smsRepotShort.Amount, (int)ChanelType.Bakcell); AddUserIncomeAbility(userID, false, "Bakcell", "Kontur", month, year, smsRepotShort.Amount, (int)ChanelType.Bakcell); } } } } } } catch (Exception ex) { } }
public List <SMSReportDTO> SW_GetSMSReports(int userID, string userName, int year) { var result = new List <SMSReportDTO>(); StringBuilder allQuery = new StringBuilder(); var query = @"select * from [GetMessageReport](@P_USERID,@P_year) "; allQuery.Append(query); using (var connection = new SqlConnection(ConnectionStrings.ConnectionString)) { connection.Open(); using (var command = new SqlCommand(allQuery.ToString(), connection)) { SqlParameter puserID = new SqlParameter("@P_USERID", SqlDbType.Int); puserID.Value = userID; command.Parameters.Add(puserID); SqlParameter pyear = new SqlParameter("@P_year", SqlDbType.Int); pyear.Value = year; command.Parameters.Add(pyear); var reader = command.ExecuteReader(); while (reader.Read()) { SMSReportDTO sMSReportDTO = new SMSReportDTO() { INOUT_EVType = reader.GetInt32OrDefaultValue(0), Name = reader.GetStringOrEmpty(1), OperationType = reader.GetStringOrEmpty(2), Year = reader.GetInt32OrDefaultValue(3), January = reader.GetDecimalOrDefaultValue2(4), February = reader.GetDecimalOrDefaultValue2(5), March = reader.GetDecimalOrDefaultValue2(6), April = reader.GetDecimalOrDefaultValue2(7), May = reader.GetDecimalOrDefaultValue2(8), June = reader.GetDecimalOrDefaultValue2(9), July = reader.GetDecimalOrDefaultValue2(10), August = reader.GetDecimalOrDefaultValue2(11), September = reader.GetDecimalOrDefaultValue2(12), October = reader.GetDecimalOrDefaultValue2(13), November = reader.GetDecimalOrDefaultValue2(14), December = reader.GetDecimalOrDefaultValue2(15), }; sMSReportDTO.Average = GetAverage(sMSReportDTO); string prefix = GetNumberPrefix(userName); tbl_OperatorInformation operatorInformation = GetAverageCost(prefix, sMSReportDTO.INOUT_EVType); if (operatorInformation != null) { if (operatorInformation.Price == null) { sMSReportDTO.AveragePrice = null; } else { sMSReportDTO.AveragePrice = sMSReportDTO.Average * (decimal)operatorInformation.Price;; } if (operatorInformation.Point == null) { sMSReportDTO.AveragePoint = null; } else { sMSReportDTO.AveragePoint = sMSReportDTO.Average * (decimal)operatorInformation.Point;; } } result.Add(sMSReportDTO); } } connection.Close(); } return(result); }