Ejemplo n.º 1
0
        public async Task TestGetOrdersAsync()
        {
            // Arrange
            var logger       = LogHelper.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService(nameof(TestGetOrdersAsync));
            var controller   = new SalesController(logger, salesService);

            // Act
            var response = await controller.GetOrdersAsync() as ObjectResult;

            var value = response.Value as IPagedResponse <OrderInfo>;

            controller.Dispose();

            // Assert
            Assert.False(value.DidError);
        }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.IsAuthenticated)
        {
            string          currentUser = User.Identity.Name;
            SalesController custmgr     = new SalesController();
            custmgr.AddOnlineCustomer(currentUser);
            DisplayCurrentCartQty();
            CurrentLoggedInUser.Text = User.Identity.Name;

            if (!Page.IsPostBack)
            {
                var loggedInGridview = (GridView)ProductsLoggedIn.FindControl("ProductsListViewLoggedIn");
                loggedInGridview.DataBind();
            }
        }
    }
Ejemplo n.º 3
0
    protected void AddToCartBtn_Click(object sender, EventArgs e)
    {
        LinkButton  linkBtn   = (LinkButton)sender;
        string      username  = User.Identity.Name;
        GridViewRow grdrow    = (GridViewRow)((LinkButton)sender).NamingContainer;
        int         productid = int.Parse(linkBtn.CommandArgument.ToString());
        int         quantity  = int.Parse((grdrow.Cells[2].FindControl("AddQtyValue") as TextBox).Text);

        MessageUserControl.TryRun(() =>
        {
            SalesController sysmgr = new SalesController();
            sysmgr.AddProductToCart(username, productid, quantity);
            var loggedInGridview = (GridView)ProductsLoggedIn.FindControl("ProductsListViewLoggedIn");
            loggedInGridview.DataBind();
            DisplayCurrentCartQty();
        }, "Added Product", "Product added to shopping cart!");
    }
Ejemplo n.º 4
0
        protected void PlaceOrderButton_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() => {
                var controller  = new SalesController();
                var paymentType = paymentRadioButton.SelectedValue;
                var coupon      = controller.GetCoupon(CouponTextBox.Text);

                if (coupon != null)
                {
                    controller.PlaceOrder(User.Identity.Name, paymentType, coupon.CouponID);
                }
                else
                {
                    controller.PlaceOrder(User.Identity.Name, paymentType, 0);
                }
            }, "Place Order", "You place a order, thank you for shopping");
        }
Ejemplo n.º 5
0
        public async Task TestGetOrdersAsync()
        {
            // Arrange
            var userInfo   = IdentityMocker.GetCustomerIdentity().GetUserInfo();
            var service    = ServiceMocker.GetSalesService(userInfo, nameof(TestGetOrdersAsync));
            var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service);

            // Act
            var response = await controller.GetOrdersAsync() as ObjectResult;

            var value = response.Value as IPagedResponse <OrderInfo>;

            service.Dispose();

            // Assert
            Assert.False(value.DidError);
        }
Ejemplo n.º 6
0
        public async Task TestGetOrderNotFoundAsync()
        {
            using (var repository = RepositoryMocker.GetSalesRepository())
            {
                // Arrange
                var controller = new SalesController(repository);
                var id         = 0;

                // Act
                var response = await controller.GetOrder(id) as ObjectResult;

                // Assert
                var value = response.Value as ISingleResponse <OrderHeaderViewModel>;

                Assert.False(value.DidError);
            }
        }
Ejemplo n.º 7
0
        public async Task TestGetOrdersSearchingBySalesOrderNumberAsync()
        {
            using (var repository = RepositoryMocker.GetSalesRepository())
            {
                // Arrange
                var controller       = new SalesController(repository);
                var salesOrderNumber = "so72";

                // Act
                var response = await controller.GetOrders(salesOrderNumber : salesOrderNumber) as ObjectResult;

                // Assert
                var value = response.Value as IListResponse <OrderSummaryViewModel>;

                Assert.False(value.DidError);
            }
        }
Ejemplo n.º 8
0
        public async Task TestGetOrdersSearchingByCustomerNameAsync()
        {
            using (var repository = RepositoryMocker.GetSalesRepository())
            {
                // Arrange
                var controller   = new SalesController(repository);
                var customerName = "her";

                // Act
                var response = await controller.GetOrders(customerName : customerName) as ObjectResult;

                // Assert
                var value = response.Value as IListResponse <OrderSummaryViewModel>;

                Assert.False(value.DidError);
            }
        }
Ejemplo n.º 9
0
        protected void AvailableProducts_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList dropDown = (DropDownList)sender;

            // container is current row of Listview,
            // which holds the dropdownlist that caused postback
            if (dropDown.SelectedIndex > 0)
            {
                var controller = new SalesController();
                var product    = controller.GetProduct(int.Parse(dropDown.SelectedValue));
                ResetInsertItemDefaultValues(dropDown, 1, product.UnitPrice, 0);
            }
            else
            {
                ResetInsertItemDefaultValues(dropDown, 0, 0, 0);
            }
        }
Ejemplo n.º 10
0
        public async Task TestGetOrdersAsync()
        {
            using (var repository = RepositoryMocker.GetSalesRepository())
            {
                // Arrange
                var controller = new SalesController(repository);

                // Act
                var response = await controller.GetOrders() as ObjectResult;

                // Assert
                var value = response.Value as IListResponse <OrderSummaryViewModel>;

                Assert.False(value.DidError);
                Assert.True(value.Model.Count() > 0);
            }
        }
Ejemplo n.º 11
0
        protected void CustomerOrderHistoryGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            // if selected
            if (CustomerOrderHistoryGridView.SelectedIndex >= 0)
            {
                //    disable the NewOrder button
                //    prepare the OrderItemsListView
                int orderId    = int.Parse(CustomerOrderHistoryGridView.SelectedValue.ToString());
                var controller = new SalesController();
                var order      = controller.GetExistingOrder(orderId);

                SetupEditOrderForm(order);
                //    if order is shipped
                //        disable the OrderItemsListView
            }
            // else
            //    enable the NewOrder button
        }
Ejemplo n.º 12
0
 protected void Refresh_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() => {
         var controller = new SalesController();
         var coupon     = controller.GetCoupon(CouponTextBox.Text);
         if (coupon == null)
         {
             Discount.Text = "$0.00";
             Total.Text    = SubTotal.Text;
             throw new Exception("This coupon doesn't exist. Try again.");
         }
         else
         {
             Discount.Text = (coupon.CouponDiscount / 100.0 * double.Parse(SubTotal.Text.Substring(1))).ToString("C");
             Total.Text    = (double.Parse(SubTotal.Text.Substring(1)) - double.Parse(Discount.Text.Substring(1))).ToString("C");
         }
     }, "Refresh", "updated discount");
 }
Ejemplo n.º 13
0
        public async Task GetCreateOrderViewModelTestAsync()
        {
            // Arrange
            var humanResourcesBusinessObject = BusinessObjectMocker.GetHumanResourcesBusinessObject();
            var productionBusinessObject     = BusinessObjectMocker.GetProductionBusinessObject();
            var salesBusinessObject          = BusinessObjectMocker.GetSalesBusinessObject();

            using (var controller = new SalesController(null, humanResourcesBusinessObject, productionBusinessObject, salesBusinessObject))
            {
                // Act
                var response = await controller.GetCreateOrderViewModel() as ObjectResult;

                // Assert
                var value = response.Value as ISingleModelResponse <CreateOrderViewModel>;

                Assert.False(value.DidError);
            }
        }
Ejemplo n.º 14
0
        protected void RefundButton_Click(object sender, EventArgs e)
        {
            SalesController sc = new SalesController();

            MessageUserControl.TryRun(() =>
            {
                RefundInvoiceTextBoxDisplay.Text = sc.Do_RefundTransaction(DumpGridView()).ToString();
            }, "Success", "Refund Completed");

            TextBox textBox = new TextBox();

            foreach (GridViewRow row in InvoiceGridView.Rows)
            {
                textBox          = (TextBox)row.FindControl("Reason");
                textBox.ReadOnly = true;
            }
            RefundButton.Enabled = false;
        }
Ejemplo n.º 15
0
        public void AddStock()
        {
            ISalesController userController = new SalesController();
            Stock            stock          = new Stock()
            {
                Item_Id     = 1,
                UnitPrice   = 10,
                TotalPrice  = 20,
                Quantity    = 2,
                CreatedAt   = DateTime.Now,
                CompanyName = "Lojitech",
                EntityState = EntityState.Added
            };

            userController.ManageStock(stock, stock.EntityState);
            Assert.AreNotEqual(null, userController.GetItems(true).FirstOrDefault(x => x.Id.Equals(stock.Item_Id)).Stocks.FirstOrDefault(x => x.Id.Equals(stock.Id)));
            userController.ManageStock(stock, EntityState.Deleted);
        }
        public async Task TestGetCreateOrderRequestAsync()
        {
            // Arrange
            var logger       = LoggerMocker.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService();

            using (var controller = new SalesController(logger, salesService))
            {
                // Act
                var response = await controller.GetCreateOrderRequestAsync() as ObjectResult;

                var value = response.Value as ISingleResponse <CreateOrderRequest>;

                // Assert
                Assert.False(value.DidError);
                Assert.True(value.Model.Products.Count() >= 0);
            }
        }
Ejemplo n.º 17
0
        public async Task TestCloneOrderAsync()
        {
            // Arrange
            var logger     = LoggingHelper.GetLogger <SalesController>();
            var service    = ServiceMocker.GetSalesService(nameof(TestCloneOrderAsync));
            var controller = new SalesController(logger, service);
            var id         = 1;

            // Act
            var response = await controller.CloneOrderAsync(id) as ObjectResult;

            var value = response.Value as ISingleResponse <OrderHeader>;

            service.Dispose();

            // Assert
            Assert.False(value.DidError);
        }
Ejemplo n.º 18
0
    protected void DeleteItemBtn_Click(object sender, EventArgs e)
    {
        LinkButton cmdBtn             = (LinkButton)sender;
        int        shoppingcartitemid = int.Parse(cmdBtn.CommandArgument);

        MessageUserControl.TryRun(() =>
        {
            SalesController sysmgr = new SalesController();
            sysmgr.DeleteItem(User.Identity.Name, shoppingcartitemid);
            ShoppingCartListView.DataBind();
            ShoppingCartTotal();
            DisplayCurrentCartQty();
            if (!CheckForItemsInCart())
            {
                checkoutButton.HRef = "~/Sales/PartsCatalog.aspx";
            }
        }, "Removal Successful", "Item has been removed from your cart.");
    }
Ejemplo n.º 19
0
        public void UpdateSale_WithInvalidModel_Returns_BadRequestResult()
        {
            // Arrange
            var mediatorMock     = new Mock <IMediator>();
            var loggerMock       = new Mock <ILogger <SalesController> >();
            var salesServiceMock = new Mock <ISaleStatisticService>();

            var controller = new SalesController(loggerMock.Object, mediatorMock.Object, salesServiceMock.Object);

            controller.ModelState.AddModelError("Error", "Model Error");
            var saleDTO = new SaleDTO();

            // Act
            var result = controller.UpdateSale(saleDTO).GetAwaiter().GetResult();

            // Assert
            Assert.IsType <BadRequestObjectResult>(result);
        }
        public async Task TestGetOrderAsync()
        {
            // Arrange
            var logger       = LoggerMocker.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService();
            var id           = 1;

            using (var controller = new SalesController(logger, salesService))
            {
                // Act
                var response = await controller.GetOrderAsync(id) as ObjectResult;

                var value = response.Value as ISingleResponse <Order>;

                // Assert
                Assert.False(value.DidError);
            }
        }
Ejemplo n.º 21
0
        public void SendToGarbageFromStock()
        {
            ISalesController userController = new SalesController();
            IList <Stock>    Stocks         = userController.GetItems(true).FirstOrDefault(x => x.Id.Equals(1)).Stocks.ToList();
            int quantity;

            if (Stocks != null && Stocks.Count > 0)
            {
                Stock stock = Stocks.ElementAt(0);
                quantity = Convert.ToInt32(stock.Quantity);
                userController.AddGarbage(stock, 1);
                Assert.AreEqual(quantity - 1, stock.Quantity);
            }
            else
            {
                Assert.Fail("Null exception");
            }
        }
Ejemplo n.º 22
0
        public void Sale()
        {
            SaleCreateDto sale = new SaleCreateDto();

            saleController    = new SalesController();
            productController = new ProductsController();

            Console.Write("\nUsuario id: ");
            sale.UserId = int.Parse(Console.ReadLine());
            Console.Write("\nCliente id: ");
            sale.ClientId = int.Parse(Console.ReadLine());
            Console.Write("\nEs Venta Fiada ?? S | N ");
            sale.Trusted = Console.ReadLine() == "S" ? true : false;

            SaleItemCreateDto item;
            bool @continue = true;

            while (@continue)
            {
                item = new SaleItemCreateDto();
                Console.Write("\n\nProduct Id: ");
                item.ProductId = int.Parse(Console.ReadLine());
                Products product = (Products)productController.Consult(item.ProductId);
                if (product != null)
                {
                    Console.Write("\nCantidad: ");
                    item.Quantity = int.Parse(Console.ReadLine());
                    sale.ProductList.Add(item);
                    sale.Total += product.Price;
                }
                else
                {
                    Console.Write("\n\n\tProducto no encontrado");
                }
                Console.Write("\n\nAgregar otro producto ?? S | N ");
                @continue = Console.ReadLine() == "S" ? true : false;
            }


            if (saleController.DoSale(sale))
            {
                Console.WriteLine("\nVenta registrada satisfactoriamente");
            }
        }
        public async Task TestGetOrdersByEmployeeAsync()
        {
            // Arrange
            var logger       = LoggerMocker.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService();
            var employeeID   = 1;

            using (var controller = new SalesController(logger, salesService))
            {
                // Act
                var response = await controller.GetOrdersAsync(employeeID : employeeID) as ObjectResult;

                var value = response.Value as IPagedResponse <OrderInfo>;

                // Assert
                Assert.False(value.DidError);
                Assert.True(value.Model.Where(item => item.EmployeeID == employeeID).Count() == value.Model.Count());
            }
        }
Ejemplo n.º 24
0
        public void SendToGarbageFromBorrow()
        {
            ISalesController userController = new SalesController();
            User             user           = userController.GetAllUsers(true).FirstOrDefault(x => x.Id.Equals(1));
            IList <Borrow>   Borrows        = user.Borrows.ToList();
            int quantity;

            if (Borrows != null && Borrows.Count > 0)
            {
                Borrow borrow = Borrows.ElementAt(0);
                quantity = Convert.ToInt32(borrow.Quantity);
                userController.AddGarbage(borrow, 1);
                Assert.AreEqual(quantity - 1, borrow.Quantity);
            }
            else
            {
                Assert.Fail("Null exception");
            }
        }
Ejemplo n.º 25
0
        public async Task TestGetOrdersByCustomerAsync()
        {
            // Arrange
            var logger     = LoggingHelper.GetLogger <SalesController>();
            var service    = ServiceMocker.GetSalesService(nameof(TestGetOrdersByCustomerAsync));
            var controller = new SalesController(logger, service);
            var customerID = 1;

            // Act
            var response = await controller.GetOrdersAsync(customerID : customerID) as ObjectResult;

            var value = response.Value as IPagedResponse <OrderInfo>;

            service.Dispose();

            // Assert
            Assert.False(value.DidError);
            Assert.True(value.Model.Count(item => item.CustomerID == customerID) == value.Model.Count());
        }
Ejemplo n.º 26
0
        public void GetSalesStatistic_WithMissingQueryParameter_Returns_BadRequestResult()
        {
            // Arrange
            var mediatorMock     = new Mock <IMediator>();
            var loggerMock       = new Mock <ILogger <SalesController> >();
            var salesServiceMock = new Mock <ISaleStatisticService>();

            var controller = new SalesController(loggerMock.Object, mediatorMock.Object, salesServiceMock.Object);
            var scale      = TimeUnit.Quarter;
            var startDate  = DateTime.Parse("2019-01-01");

            // Act
            var result = controller.GetSalesStatistic(scale, startDate, null).GetAwaiter().GetResult();

            // Assert
            var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(result);

            Assert.IsAssignableFrom <string>(badRequestObjectResult.Value);
        }
        public void Controller_Remove_Order_No_Error()
        {
            // Arrange
            var salesController = new SalesController(mockSalesService.Object);
            var eid             = 77;
            var rid             = -1;

            mockSalesService.Setup(nt => nt.Remove(eid)).Callback <Int32>(x => {
                rid = x;
            });

            // Action
            var ar = salesController.Delete(eid);

            // Assert
            mockSalesService.Verify(x => x.Remove(eid), Times.Once);
            Assert.AreEqual(eid, rid);
            Assert.IsInstanceOfType(ar, typeof(OkResult));
        }
Ejemplo n.º 28
0
        public async Task TestGetCreateOrderRequestAsync()
        {
            // Arrange
            var userInfo   = IdentityMocker.GetCustomerIdentity().GetUserInfo();
            var service    = ServiceMocker.GetSalesService(userInfo, nameof(TestGetCreateOrderRequestAsync));
            var controller = new SalesController(LoggingHelper.GetLogger <SalesController>(), service);

            // Act
            var response = await controller.GetCreateOrderRequestAsync() as ObjectResult;

            var value = response.Value as ISingleResponse <Core.BusinessLayer.Requests.CreateOrderRequest>;

            service.Dispose();

            // Assert
            Assert.False(value.DidError);
            Assert.True(value.Model.Products.Count() > 0);
            Assert.True(value.Model.Customers.Count() > 0);
        }
        public async Task TestGetCreateOrderRequestAsync()
        {
            // Arrange
            var logger = LoggerMocker.GetLogger <SalesController>();
            var humanResourcesBusinessObject = BusinessObjectMocker.GetHumanResourcesBusinessObject();
            var productionBusinessObject     = BusinessObjectMocker.GetProductionBusinessObject();
            var salesBusinessObject          = BusinessObjectMocker.GetSalesBusinessObject();

            using (var controller = new SalesController(logger, humanResourcesBusinessObject, productionBusinessObject, salesBusinessObject))
            {
                // Act
                var response = await controller.GetCreateOrderRequestAsync() as ObjectResult;

                var value = response.Value as ISingleResponse <CreateOrderRequest>;

                // Assert
                Assert.False(value.DidError);
            }
        }
Ejemplo n.º 30
0
    protected void UpdateQty_Click(object sender, EventArgs e)
    {
        LinkButton cmdBtn    = (LinkButton)sender;
        string     direction = cmdBtn.CommandArgument.ToString();
        int        partid    = int.Parse((cmdBtn.Parent.FindControl("ProductIdLabel") as Label).Text);

        MessageUserControl.TryRun(() =>
        {
            SalesController sysmgr = new SalesController();
            sysmgr.UpdateItem(User.Identity.Name, partid, direction);
            ShoppingCartListView.DataBind();
            ShoppingCartTotal();
            DisplayCurrentCartQty();
            if (!CheckForItemsInCart())
            {
                checkoutButton.HRef = "~/Sales/PartsCatalog.aspx";
            }
        }, "Quantity Updated", "Part Quantity has been updated");
    }
Ejemplo n.º 31
0
    /***********************************Function to Get Sales File into DataTable***********************************/
    public string getSales()
    {
        SalesController objSalesController = new SalesController();
        string lblMessage = "";
        string strPath = Server.MapPath("~/") + "UploadFile\\Sales.xls";
        string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath;

        excelConnectionString += @";Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""";
        OleDbConnection connection = new OleDbConnection(excelConnectionString);

        string Name = "";
        try
        {
            connection.Open();
            DataTable SheetName = new DataTable();
            SheetName = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            string[] excelSheets = new string[SheetName.Rows.Count];
            int i = 0;
            // Add the sheet name to the string array.
            foreach (DataRow row in SheetName.Rows)
            {

                excelSheets[i] = SheetName.Rows[0]["TABLE_NAME"].ToString();
                Name = excelSheets[i];
            }

            DataTable dtNew = new DataTable();

            string query = "Select * FROM [" + Name + "]";

            OleDbCommand command = new OleDbCommand(query, connection);
            OleDbDataAdapter dataread = new OleDbDataAdapter(command);
            DataTable dt = new DataTable();

            dataread.Fill(dt);
            dtNew = dt;

            lblMessage = SaveSales(dtNew);
            //lblMessage = "File Sales saved successfully";
            connection.Close();
            return lblMessage;

        }
        catch (Exception ex)
        {
            connection.Close();
            string strMessage = ex.Message.ToString();

            if (strMessage == "External table is not in the expected format." || strMessage.Contains("does not belong to table"))
            {
                lblMessage = "Excel file is not in valid format";
            }
            else
            {
                lblMessage = "File Sales could not be saved successfully";
            }
            return lblMessage;
        }
    }
Ejemplo n.º 32
0
    /***********************************Function to Save Sales File into Sql Server 2000 using Bulk Copy Method***********************************/
    public string SaveSales(DataTable dt)
    {
        string lblMessage = "";

        SalesController objCont = new SalesController();
        string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString();

        //try
        //{
        //    string strDelete = "Delete from SalesTemp";
        //    objController.ExecuteQuery(strDelete);

        //    SqlConnection sqlconn = new SqlConnection(sConnectionString);
        //    sqlconn.Open();
        //    SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlconn);
        //    bulkCopy.DestinationTableName = "SalesTemp";
        //    bulkCopy.WriteToServer(dt);
        //}
        //catch
        //{
        //}
        DataTable dtMonthOC = new DataTable();
        string strMonthOCQuery = "select * from MonthOpenClose";
        dtMonthOC = objController.ExecuteQuery(strMonthOCQuery);
        DataView dvMonthOC = new DataView(dtMonthOC);
        DataTable dtFilter = new DataTable();
        string[] strFromSalesMonth = txtSalesFromDate.Text.Trim().Split('/');
        int FromMonth = Convert.ToInt16(strFromSalesMonth[1]);
        //int FromMonth = CalSalesfromDate.SelectedDate.Month;
        dvMonthOC.RowFilter = "MonthID =" + FromMonth;
        dtFilter = dvMonthOC.ToTable();

        if (dtFilter.Rows != null)
        {
            bool OCStatus = Convert.ToBoolean(dtFilter.Rows[0]["Status"]);

            if (OCStatus == false)
            {
                lblMessage = "Month is Closed, Please open month to enter data";
            }
            else
            {
                string[] strToSalesDate = txtSalesToDate.Text.Trim().Split('/');
                //int ToMonth = CalSalestoDate.SelectedDate.Month;
                int ToMonth = Convert.ToInt16(strToSalesDate[1]);
                int rcount = 0;

                foreach (DataRow dr in dt.Rows)
                {

                    int IsModelEx = 1;
                    SalesUI objUI = new SalesUI();
                    try
                    {
                        objUI.Sno = Convert.ToInt32(dr["Sno"]);
                        if (dr["Inv#No"].ToString() == "7253102")
                        {
                            string strTest = "";
                        }
                        objUI.InvoiceNo = Convert.ToInt32(dr["Inv#No"]);
                        //objUI.Date = Convert.ToString(dr["Date"]);

                        string strDate = Convert.ToString(dr["Date"]);
                        if (strDate == "" || strDate == "00.00.0000")
                        {
                            objUI.Date = Convert.ToDateTime("1/1/2001");
                        }
                        else
                        {
                            objUI.Date = Convert.ToDateTime(ConvertDateTime(Convert.ToString(dr["Date"])));
                        }

                        objUI.Dealer_Code = Convert.ToString(dr["DlrCode"]);
                        objUI.Dealer_Name = Convert.ToString(dr["Dlr Name"]);
                        objUI.Blank = Convert.ToString(dr["F10"]);
                        string strMaterial = dr["F10"].ToString();

                        string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'";
                        DataTable dtModel = objController.ExecuteQuery(strModelQuery);

                        if (dtModel != null)
                        {
                            if (dtModel.Rows.Count > 0)
                            {
                                foreach (DataRow drModel in dtModel.Rows)
                                {
                                    objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString());
                                    IsModelEx = 0;
                                }

                            }

                        }

                        objUI.Model_Code = Convert.ToString(dr["Model Code"]);
                        string strQuantity = Convert.ToString(dr["Qty"]);
                        if (strQuantity == "")
                        {
                            objUI.Quantity = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.Quantity = Convert.ToInt32(dr["Qty"]);
                        }

                        string strSaleAmt = dr["Sale Amt"].ToString();
                        if (strSaleAmt == "")
                        {
                            objUI.SalesAmount = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.SalesAmount = Convert.ToDouble(dr["Sale Amt"]);
                        }

                        string strDiscount = Convert.ToString(dr["Discount"]);
                        if (strDiscount == "")
                        {
                            objUI.Discount = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.Discount = Convert.ToInt32(dr["Discount"]);
                        }

                        string strSPLDIS = Convert.ToString(dr["SPL#DIS"]);
                        if (strSPLDIS == "")
                        {
                            objUI.SPLDIS = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.SPLDIS = Convert.ToDouble(dr["SPL#DIS"]);
                        }

                        string strExciseDuty = Convert.ToString(dr["Excise Duty"]);
                        if (strExciseDuty == "")
                        {
                            objUI.ExciseDuty = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.ExciseDuty = Convert.ToInt32(dr["Excise Duty"]);
                        }

                        //objUI.Edu_Cess = Convert.ToInt32(dr["Edu# Cess"]);
                        //objUI.HR_ECess = Convert.ToInt32(dr["Hr#ECess"]);

                        string strEdu_Cess = Convert.ToString(dr["Edu# Cess"]);
                        if (strEdu_Cess == "")
                        {
                            objUI.Edu_Cess = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.Edu_Cess = Convert.ToInt32(dr["Edu# Cess"]);
                        }

                        string strHRECess = Convert.ToString(dr["Hr#ECess"]);
                        if (strHRECess == "")
                        {
                            objUI.HR_ECess = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.HR_ECess = Convert.ToInt32(dr["Hr#ECess"]);
                        }

                        string strLSPD = Convert.ToString(dr["LSPD"]);
                        if (strLSPD == "")
                        {
                            objUI.LSPD = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.LSPD = Convert.ToInt32(dr["LSPD"]);
                        }

                        string strMSPSD = Convert.ToString(dr["MSPSD"]);
                        if (strMSPSD == "")
                        {
                            objUI.MSPSD = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.MSPSD = Convert.ToInt32(dr["MSPSD"]);
                        }

                        string strDHC = Convert.ToString(dr["DHC"]);
                        if (strDHC == "")
                        {
                            objUI.DHC = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.DHC = Convert.ToInt32(dr["DHC"]);
                        }

                        string strTaxable = Convert.ToString(dr["Taxable"]);
                        if (strTaxable == "")
                        {
                            objUI.Taxable = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.Taxable = Convert.ToDouble(dr["Taxable"]);
                        }

                        string strCST = Convert.ToString(dr["CST"]);
                        if (strCST == "")
                        {
                            objUI.CST = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.CST = Convert.ToDouble(dr["CST"]);
                        }

                        string strLST = Convert.ToString(dr["LST"]);
                        if (strLST == "")
                        {
                            objUI.LST = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.LST = Convert.ToDouble(dr["LST"]);
                        }

                        string strSurch = Convert.ToString(dr["Surch"]);
                        if (strSurch == "")
                        {
                            objUI.Surch = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.Surch = Convert.ToInt32(dr["Surch"]);
                        }

                        string strDely_Chgs = Convert.ToString(dr["Dely Chgs"]);
                        if (strDely_Chgs == "")
                        {
                            objUI.Dely_Chgs = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.Dely_Chgs = Convert.ToInt32(dr["Dely Chgs"]);
                        }

                        string strEntityTot = Convert.ToString(dr["Enty/TOT"]);
                        if (strEntityTot == "")
                        {
                            objUI.EntityTot = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.EntityTot = Convert.ToDouble(dr["Enty/TOT"]);
                        }

                        string strFreight = Convert.ToString(dr["Freight"]);
                        if (strFreight == "")
                        {
                            objUI.Freight = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.Freight = Convert.ToDouble(dr["Freight"]);
                        }
                        string strNetAmount = Convert.ToString(dr["Net Amount"]);
                        if (strNetAmount == "")
                        {
                            objUI.Net_Amount = Convert.ToDouble(null);
                        }
                        else
                        {
                            objUI.Net_Amount = Convert.ToDouble(dr["Net Amount"]);
                        }

                        string strCost = Convert.ToString(dr["Cost"]);
                        if (strCost == "")
                        {
                            objUI.Cost = Convert.ToInt32(null);
                        }
                        else
                        {
                            objUI.Cost = Convert.ToInt32(dr["Cost"]);
                        }
                        objUI.SOff = Convert.ToString(dr["S#Off"]);
                        //objUI.FromDate = CalSalesfromDate.SelectedDate;
                        //objUI.ToDate = CalSalestoDate.SelectedDate;
                        objUI.FromDate = Convert.ToDateTime(objUtility.ConvertDateTime(txtSalesFromDate.Text.Trim()));
                        objUI.ToDate = Convert.ToDateTime(objUtility.ConvertDateTime(txtSalesToDate.Text.Trim()));

                        if (IsModelEx == 0)
                        {
                            objCont.SaveSales(objUI);
                            rcount++;
                        }
                        else
                        {
                            string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) ";
                            strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + objUtility.ConvertDateTime(txtSalesFromDate.Text.Trim()) + "','" + objUtility.ConvertDateTime(txtSalesToDate.Text.Trim()) + "'," + IsModelEx + ")";
                            objController.ExecuteQuery(strQuery);
                        }

                        lblMessage = "File Sales saved successfully;No of Rows Affected:" + rcount;
                    }
                    catch
                    {
                        lnkSalesException.Visible = true;
                        string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) ";
                        strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + objUtility.ConvertDateTime(txtSalesFromDate.Text.Trim()) + "','" + objUtility.ConvertDateTime(txtSalesToDate.Text.Trim()) + "'," + IsModelEx + ")";
                        objController.ExecuteQuery(strQuery);
                    }

                }

            }
        }
        return lblMessage;
    }
Ejemplo n.º 33
0
    public string SaveSales(DataTable dt)
    {
        string lblMessage = "";

        SalesController objCont = new SalesController();
        string sConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString();

        int rcount = 0;

        foreach (DataRow dr in dt.Rows)
        {

            int IsModelEx = 1;
            int SalesID = Convert.ToInt32(dr["ID"].ToString());
            SalesUI objUI = new SalesUI();
            try
            {
                objUI.Sno = Convert.ToInt32(dr["Sno"]);
                objUI.InvoiceNo = Convert.ToInt32(dr["Inv#No"]);
                string strDate = Convert.ToString(dr["Date"]);
                if (strDate == "" || strDate == "00.00.0000")
                {
                    objUI.Date = Convert.ToDateTime("1/1/2001");
                }
                else
                {
                    objUI.Date = Convert.ToDateTime(ConvertDateTime(Convert.ToString(dr["Date"])));
                }

                objUI.Dealer_Code = Convert.ToString(dr["DlrCode"]);
                objUI.Dealer_Name = Convert.ToString(dr["Dlr Name"]);
                objUI.Blank = Convert.ToString(dr["F10"]);
                string strMaterial = dr["F10"].ToString();

                string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'";
                DataTable dtModel = objQueryController.ExecuteQuery(strModelQuery);

                if (dtModel != null)
                {
                    if (dtModel.Rows.Count > 0)
                    {
                        foreach (DataRow drModel in dtModel.Rows)
                        {
                            objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString());
                            IsModelEx = 0;
                        }

                    }

                }

                objUI.Model_Code = Convert.ToString(dr["Model Code"]);
                objUI.Quantity = Convert.ToInt32(dr["Qty"]);
                objUI.SalesAmount = Convert.ToDouble(dr["Sale Amt"]);

                string strDiscount = Convert.ToString(dr["Discount"]);
                if (strDiscount == "")
                {
                    objUI.Discount = Convert.ToInt32(null);
                }
                else
                {
                    objUI.Discount = Convert.ToInt32(dr["Discount"]);
                }

                string strSPLDIS = Convert.ToString(dr["SPL#DIS"]);
                if (strSPLDIS == "")
                {
                    objUI.SPLDIS = Convert.ToDouble(null);
                }
                else
                {
                    objUI.SPLDIS = Convert.ToDouble(dr["SPL#DIS"]);
                }

                string strExciseDuty = Convert.ToString(dr["Excise Duty"]);
                if (strExciseDuty == "")
                {
                    objUI.ExciseDuty = Convert.ToInt32(null);
                }
                else
                {
                    objUI.ExciseDuty = Convert.ToInt32(dr["Excise Duty"]);
                }

                objUI.Edu_Cess = Convert.ToInt32(dr["Edu# Cess"]);
                objUI.HR_ECess = Convert.ToInt32(dr["Hr#ECess"]);

                string strLSPD = Convert.ToString(dr["LSPD"]);
                if (strLSPD == "")
                {
                    objUI.LSPD = Convert.ToInt32(null);
                }
                else
                {
                    objUI.LSPD = Convert.ToInt32(dr["LSPD"]);
                }

                string strMSPSD = Convert.ToString(dr["MSPSD"]);
                if (strMSPSD == "")
                {
                    objUI.MSPSD = Convert.ToInt32(null);
                }
                else
                {
                    objUI.MSPSD = Convert.ToInt32(dr["MSPSD"]);
                }

                string strDHC = Convert.ToString(dr["DHC"]);
                if (strDHC == "")
                {
                    objUI.DHC = Convert.ToInt32(null);
                }
                else
                {
                    objUI.DHC = Convert.ToInt32(dr["DHC"]);
                }

                string strTaxable = Convert.ToString(dr["Taxable"]);
                if (strTaxable == "")
                {
                    objUI.Taxable = Convert.ToDouble(null);
                }
                else
                {
                    objUI.Taxable = Convert.ToDouble(dr["Taxable"]);
                }

                string strCST = Convert.ToString(dr["CST"]);
                if (strCST == "")
                {
                    objUI.CST = Convert.ToDouble(null);
                }
                else
                {
                    objUI.CST = Convert.ToDouble(dr["CST"]);
                }

                string strLST = Convert.ToString(dr["LST"]);
                if (strLST == "")
                {
                    objUI.LST = Convert.ToDouble(null);
                }
                else
                {
                    objUI.LST = Convert.ToDouble(dr["LST"]);
                }

                string strSurch = Convert.ToString(dr["Surch"]);
                if (strSurch == "")
                {
                    objUI.Surch = Convert.ToInt32(null);
                }
                else
                {
                    objUI.Surch = Convert.ToInt32(dr["Surch"]);
                }

                string strDely_Chgs = Convert.ToString(dr["Dely Chgs"]);
                if (strDely_Chgs == "")
                {
                    objUI.Dely_Chgs = Convert.ToInt32(null);
                }
                else
                {
                    objUI.Dely_Chgs = Convert.ToInt32(dr["Dely Chgs"]);
                }

                string strEntityTot = Convert.ToString(dr["Enty/TOT"]);
                if (strEntityTot == "")
                {
                    objUI.EntityTot = Convert.ToInt32(null);
                }
                else
                {
                    objUI.EntityTot = Convert.ToInt32(dr["Enty/TOT"]);
                }

                string strFreight = Convert.ToString(dr["Freight"]);
                if (strFreight == "")
                {
                    objUI.Freight = Convert.ToDouble(null);
                }
                else
                {
                    objUI.Freight = Convert.ToDouble(dr["Freight"]);
                }
                objUI.Net_Amount = Convert.ToDouble(dr["Net Amount"]);
                objUI.Cost = Convert.ToInt32(dr["Cost"]);
                objUI.SOff = Convert.ToString(dr["S#Off"]);
                objUI.FromDate = Convert.ToDateTime(dr["FromDate"].ToString());
                objUI.ToDate = Convert.ToDateTime(dr["ToDate"].ToString());

                if (IsModelEx == 0)
                {
                    objCont.SaveSales(objUI);
                    rcount++;
                }
                else
                {
                    string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) ";
                    strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "'," + IsModelEx + ")";
                    objQueryController.ExecuteQuery(strQuery);
                }

                lblMessage = "File Sales saved successfully;No of Rows Affected:" + rcount;
            }
            catch
            {
                string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[IsApproved],[FromDate],[ToDate],IsModelEx) ";
                strQuery += "Values ('" + dr["Sno"].ToString() + "','" + dr["Inv#No"].ToString() + "','" + dr["Date"].ToString() + "','" + dr["DlrCode"].ToString() + "','" + dr["Dlr Name"].ToString() + "','" + dr["F10"].ToString() + "','" + dr["Model Code"].ToString() + "','" + dr["Qty"].ToString() + "','" + dr["Sale Amt"].ToString() + "','" + dr["Discount"].ToString() + "','" + dr["SPL#DIS"].ToString() + "','" + dr["Excise Duty"].ToString() + "','" + dr["Edu# Cess"].ToString() + "','" + dr["Hr#ECess"].ToString() + "','" + dr["LSPD"].ToString() + "','" + dr["MSPSD"].ToString() + "','" + dr["DHC"].ToString() + "','" + dr["Taxable"].ToString() + "','" + dr["CST"].ToString() + "','" + dr["LST"].ToString() + "','" + dr["Surch"].ToString() + "','" + dr["Enty/TOT"].ToString() + "','" + dr["Dely Chgs"].ToString() + "','" + dr["Freight"].ToString() + "','" + dr["Net Amount"].ToString() + "','" + dr["Cost"].ToString() + "','" + dr["S#off"] + "',0,'" + dr["FromDate"].ToString() + "','" + dr["ToDate"].ToString() + "'," + IsModelEx + ")";
                objQueryController.ExecuteQuery(strQuery);
            }

            string strDeleteQuery = "Delete from SalesTemp where [ID]=" + SalesID;
            objQueryController.ExecuteQuery(strDeleteQuery);

        }

        return lblMessage;
    }
Ejemplo n.º 34
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        SalesController objCont = new SalesController();
        int rcount = 0;
        foreach (GridViewRow gr in grdSalesException.Rows)
        {
            bool Discard = ((CheckBox)gr.FindControl("chkDiscard")).Checked;
            string str = ((HiddenField)gr.FindControl("hdnID")).Value;
            if (Discard == true)
            {
                string strDiscardQuery = "Delete from SalesTemp where ID=" + Convert.ToInt16(str);
                objQueryController.ExecuteQuery(strDiscardQuery);

                string strQuery = "Select * from SalesTemp";
                DataTable dt = new DataTable();
                dt = objQueryController.ExecuteQuery(strQuery);

                grdSalesException.DataSource = dt;
                grdSalesException.DataBind();
            }
            else
            {
                SalesUI objUI = new SalesUI();
                try
                {
                    objUI.Sno = Convert.ToInt16(((TextBox)gr.FindControl("txtSno")).Text);
                    objUI.InvoiceNo = Convert.ToInt32(((TextBox)gr.FindControl("txtInvoiceNo")).Text);
                    //objUI.Date = Convert.ToString(((TextBox)gr.FindControl("txtDate")).Text);
                    string strDate = Convert.ToString(((TextBox)gr.FindControl("txtDate")).Text);
                    if (strDate == "" || strDate == "00.00.0000")
                    {
                        objUI.Date = Convert.ToDateTime("1/1/2001");
                    }
                    else
                    {
                        objUI.Date = Convert.ToDateTime(ConvertDateTime(((TextBox)gr.FindControl("txtDate")).Text));
                    }
                    objUI.Dealer_Code = Convert.ToString(((TextBox)gr.FindControl("txtDealerCode")).Text);
                    objUI.Dealer_Name = Convert.ToString(((TextBox)gr.FindControl("txtDealerName")).Text);
                    objUI.Blank = Convert.ToString(((TextBox)gr.FindControl("txtBlank")).Text);
                    string strMaterial = Convert.ToString(((TextBox)gr.FindControl("txtBlank")).Text);
                    objUI.Model_Code = Convert.ToString(((TextBox)gr.FindControl("txtModelCode")).Text);
                    objUI.Quantity = Convert.ToInt16(((TextBox)gr.FindControl("txtQuantity")).Text);
                    objUI.SalesAmount = Convert.ToDouble(((TextBox)gr.FindControl("txtSalesAmt")).Text);

                    string strDiscount = Convert.ToString(((TextBox)gr.FindControl("txtDiscount")).Text);
                    if (strDiscount == "")
                    {
                        objUI.Discount = Convert.ToInt32(null);
                    }
                    else
                    {
                        objUI.Discount = Convert.ToInt32(((TextBox)gr.FindControl("txtDiscount")).Text);
                    }

                    string strSPLDIS = Convert.ToString(((TextBox)gr.FindControl("txtSPLDIS")).Text);
                    if (strSPLDIS == "")
                    {
                        objUI.SPLDIS = Convert.ToDouble(null);
                    }
                    else
                    {
                        objUI.SPLDIS = Convert.ToDouble(((TextBox)gr.FindControl("txtSPLDIS")).Text);
                    }

                    string strExciseDuty = Convert.ToString(((TextBox)gr.FindControl("txtExciseDuty")).Text);
                    if (strExciseDuty == "")
                    {
                        objUI.ExciseDuty = Convert.ToInt16(null);
                    }
                    else
                    {
                        objUI.ExciseDuty = Convert.ToInt16(((TextBox)gr.FindControl("txtExciseDuty")).Text);
                    }

                    objUI.Edu_Cess = Convert.ToInt16(((TextBox)gr.FindControl("txtEduCess")).Text);
                    objUI.HR_ECess = Convert.ToInt16(((TextBox)gr.FindControl("txtHrECess")).Text);

                    string strLSPD = Convert.ToString(((TextBox)gr.FindControl("txtLSPD")).Text);
                    if (strLSPD == "")
                    {
                        objUI.LSPD = Convert.ToInt16(null);
                    }
                    else
                    {
                        objUI.LSPD = Convert.ToInt16(((TextBox)gr.FindControl("txtLSPD")).Text);
                    }

                    string strMSPSD = Convert.ToString(((TextBox)gr.FindControl("txtMSPSD")).Text);
                    if (strMSPSD == "")
                    {
                        objUI.MSPSD = Convert.ToInt16(null);
                    }
                    else
                    {
                        objUI.MSPSD = Convert.ToInt16(((TextBox)gr.FindControl("txtMSPSD")).Text);
                    }

                    string strDHC = Convert.ToString(((TextBox)gr.FindControl("txtDHC")).Text);
                    if (strDHC == "")
                    {
                        objUI.DHC = Convert.ToInt16(null);
                    }
                    else
                    {
                        objUI.DHC = Convert.ToInt16(((TextBox)gr.FindControl("txtDHC")).Text);
                    }

                    string strTaxable = Convert.ToString(((TextBox)gr.FindControl("txtTaxable")).Text);
                    if (strTaxable == "")
                    {
                        objUI.Taxable = Convert.ToDouble(null);
                    }
                    else
                    {
                        objUI.Taxable = Convert.ToDouble(((TextBox)gr.FindControl("txtTaxable")).Text);
                    }

                    string strCST = Convert.ToString(((TextBox)gr.FindControl("txtCST")).Text);
                    if (strCST == "")
                    {
                        objUI.CST = Convert.ToDouble(null);
                    }
                    else
                    {
                        objUI.CST = Convert.ToDouble(((TextBox)gr.FindControl("txtCST")).Text);
                    }

                    string strLST = Convert.ToString(((TextBox)gr.FindControl("txtLST")).Text);
                    if (strLST == "")
                    {
                        objUI.LST = Convert.ToDouble(null);
                    }
                    else
                    {
                        objUI.LST = Convert.ToDouble(((TextBox)gr.FindControl("txtLST")).Text);
                    }

                    string strSurch = Convert.ToString(((TextBox)gr.FindControl("txtSurch")).Text);
                    if (strSurch == "")
                    {
                        objUI.Surch = Convert.ToInt16(null);
                    }
                    else
                    {
                        objUI.Surch = Convert.ToInt16(((TextBox)gr.FindControl("txtSurch")).Text);
                    }

                    string strDely_Chgs = Convert.ToString(((TextBox)gr.FindControl("txtDelyChgs")).Text);
                    if (strDely_Chgs == "")
                    {
                        objUI.Dely_Chgs = Convert.ToInt16(null);
                    }
                    else
                    {
                        objUI.Dely_Chgs = Convert.ToInt16(((TextBox)gr.FindControl("txtDelyChgs")).Text);
                    }

                    string strEntityTot = Convert.ToString(((TextBox)gr.FindControl("txtEntityTot")).Text);
                    if (strEntityTot == "")
                    {
                        objUI.EntityTot = Convert.ToInt16(null);
                    }
                    else
                    {
                        objUI.EntityTot = Convert.ToInt16(((TextBox)gr.FindControl("txtEntityTot")).Text);
                    }

                    string strFreight = Convert.ToString(((TextBox)gr.FindControl("txtFreight")).Text);
                    if (strFreight == "")
                    {
                        objUI.Freight = Convert.ToDouble(null);
                    }
                    else
                    {
                        objUI.Freight = Convert.ToDouble(((TextBox)gr.FindControl("txtFreight")).Text);
                    }
                    objUI.Net_Amount = Convert.ToDouble(((TextBox)gr.FindControl("txtNetAmt")).Text);
                    objUI.Cost = Convert.ToInt16(((TextBox)gr.FindControl("txtCost")).Text);
                    objUI.SOff = Convert.ToString(((TextBox)gr.FindControl("txtSOff")).Text);
                    objUI.FromDate = Convert.ToDateTime(gr.Cells[27].Text);
                    objUI.ToDate = Convert.ToDateTime(gr.Cells[28].Text);
                    string strModelQuery = "Select * from ModelMapping where Material='" + strMaterial + "'";
                    DataTable dtModel = objQueryController.ExecuteQuery(strModelQuery);
                    if (dtModel != null)
                    {
                        if (dtModel.Rows.Count > 0)
                        {
                            foreach (DataRow drModel in dtModel.Rows)
                            {
                                objUI.ModelMappingID = Convert.ToInt32(drModel["ID"].ToString());
                            }

                            objCont.SaveSales(objUI);
                            rcount++;
                        }
                        else
                        {
                            string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[FromDate],[ToDate])";
                            strQuery += "Values ('" + ((TextBox)gr.FindControl("txtSno")).Text + "','" + ((TextBox)gr.FindControl("txtInvoiceNo")).Text + "','" + ((TextBox)gr.FindControl("txtDate")).Text + "','" + ((TextBox)gr.FindControl("txtDealerCode")).Text + "','" + ((TextBox)gr.FindControl("txtDealerName")).Text + "','" + ((TextBox)gr.FindControl("txtBlank")).Text + "','" + ((TextBox)gr.FindControl("txtModelCode")).Text + "','" + ((TextBox)gr.FindControl("txtQuantity")).Text + "','" + ((TextBox)gr.FindControl("txtSalesAmt")).Text + "','" + ((TextBox)gr.FindControl("txtDiscount")).Text + "','" + ((TextBox)gr.FindControl("txtSPLDIS")).Text + "','" + ((TextBox)gr.FindControl("txtExciseDuty")).Text + "','" + ((TextBox)gr.FindControl("txtEduCess")).Text + "','" + ((TextBox)gr.FindControl("txtHrECess")).Text + "','" + ((TextBox)gr.FindControl("txtLSPD")).Text + "','" + ((TextBox)gr.FindControl("txtMSPSD")).Text + "','" + ((TextBox)gr.FindControl("txtDHC")).Text + "','" + ((TextBox)gr.FindControl("txtTaxable")).Text + "','" + ((TextBox)gr.FindControl("txtCST")).Text + "','" + ((TextBox)gr.FindControl("txtLST")).Text + "','" + ((TextBox)gr.FindControl("txtSurch")).Text + "','" + ((TextBox)gr.FindControl("txtEntityTot")).Text + "','" + ((TextBox)gr.FindControl("txtDelyChgs")).Text + "','" + ((TextBox)gr.FindControl("txtFreight")).Text + "','" + ((TextBox)gr.FindControl("txtNetAmt")).Text + "','" + ((TextBox)gr.FindControl("txtCost")).Text + "','" + ((TextBox)gr.FindControl("txtSOff")).Text + "','" + Convert.ToDateTime(gr.Cells[27].Text) + "','" + Convert.ToDateTime(gr.Cells[28].Text) + "')";
                            objQueryController.ExecuteQuery(strQuery);
                        }

                    }
                    else
                    {
                        string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[FromDate],[ToDate])";
                        strQuery += "Values ('" + ((TextBox)gr.FindControl("txtSno")).Text + "','" + ((TextBox)gr.FindControl("txtInvoiceNo")).Text + "','" + ((TextBox)gr.FindControl("txtDate")).Text + "','" + ((TextBox)gr.FindControl("txtDealerCode")).Text + "','" + ((TextBox)gr.FindControl("txtDealerName")).Text + "','" + ((TextBox)gr.FindControl("txtBlank")).Text + "','" + ((TextBox)gr.FindControl("txtModelCode")).Text + "','" + ((TextBox)gr.FindControl("txtQuantity")).Text + "','" + ((TextBox)gr.FindControl("txtSalesAmt")).Text + "','" + ((TextBox)gr.FindControl("txtDiscount")).Text + "','" + ((TextBox)gr.FindControl("txtSPLDIS")).Text + "','" + ((TextBox)gr.FindControl("txtExciseDuty")).Text + "','" + ((TextBox)gr.FindControl("txtEduCess")).Text + "','" + ((TextBox)gr.FindControl("txtHrECess")).Text + "','" + ((TextBox)gr.FindControl("txtLSPD")).Text + "','" + ((TextBox)gr.FindControl("txtMSPSD")).Text + "','" + ((TextBox)gr.FindControl("txtDHC")).Text + "','" + ((TextBox)gr.FindControl("txtTaxable")).Text + "','" + ((TextBox)gr.FindControl("txtCST")).Text + "','" + ((TextBox)gr.FindControl("txtLST")).Text + "','" + ((TextBox)gr.FindControl("txtSurch")).Text + "','" + ((TextBox)gr.FindControl("txtEntityTot")).Text + "','" + ((TextBox)gr.FindControl("txtDelyChgs")).Text + "','" + ((TextBox)gr.FindControl("txtFreight")).Text + "','" + ((TextBox)gr.FindControl("txtNetAmt")).Text + "','" + ((TextBox)gr.FindControl("txtCost")).Text + "','" + ((TextBox)gr.FindControl("txtSOff")).Text + "','" + Convert.ToDateTime(gr.Cells[27].Text) + "','" + Convert.ToDateTime(gr.Cells[28].Text) + "')";
                        objQueryController.ExecuteQuery(strQuery);
                    }

                }
                catch
                {
                    string strQuery = "Insert into SalesTemp ([Sno],[Inv#No],[Date],[DlrCode],[Dlr Name],[F10],[Model Code],[Qty],[Sale Amt],[Discount],[SPL#DIS],[Excise Duty],[Edu# Cess],[Hr#ECess],[LSPD],[MSPSD],[DHC],[Taxable],[CST],[LST],[Surch],[Enty/TOT],[Dely Chgs],[Freight],[Net Amount],[Cost],[S#off],[FromDate],[ToDate])";
                    strQuery += "Values ('" + ((TextBox)gr.FindControl("txtSno")).Text + "','" + ((TextBox)gr.FindControl("txtInvoiceNo")).Text + "','" + ((TextBox)gr.FindControl("txtDate")).Text + "','" + ((TextBox)gr.FindControl("txtDealerCode")).Text + "','" + ((TextBox)gr.FindControl("txtDealerName")).Text + "','" + ((TextBox)gr.FindControl("txtBlank")).Text + "','" + ((TextBox)gr.FindControl("txtModelCode")).Text + "','" + ((TextBox)gr.FindControl("txtQuantity")).Text + "','" + ((TextBox)gr.FindControl("txtSalesAmt")).Text + "','" + ((TextBox)gr.FindControl("txtDiscount")).Text + "','" + ((TextBox)gr.FindControl("txtSPLDIS")).Text + "','" + ((TextBox)gr.FindControl("txtExciseDuty")).Text + "','" + ((TextBox)gr.FindControl("txtEduCess")).Text + "','" + ((TextBox)gr.FindControl("txtHrECess")).Text + "','" + ((TextBox)gr.FindControl("txtLSPD")).Text + "','" + ((TextBox)gr.FindControl("txtMSPSD")).Text + "','" + ((TextBox)gr.FindControl("txtDHC")).Text + "','" + ((TextBox)gr.FindControl("txtTaxable")).Text + "','" + ((TextBox)gr.FindControl("txtCST")).Text + "','" + ((TextBox)gr.FindControl("txtLST")).Text + "','" + ((TextBox)gr.FindControl("txtSurch")).Text + "','" + ((TextBox)gr.FindControl("txtEntityTot")).Text + "','" + ((TextBox)gr.FindControl("txtDelyChgs")).Text + "','" + ((TextBox)gr.FindControl("txtFreight")).Text + "','" + ((TextBox)gr.FindControl("txtNetAmt")).Text + "','" + ((TextBox)gr.FindControl("txtCost")).Text + "','" + ((TextBox)gr.FindControl("txtSOff")).Text + "','" + Convert.ToDateTime(gr.Cells[27].Text) + "','" + Convert.ToDateTime(gr.Cells[28].Text) +"')";
                    objQueryController.ExecuteQuery(strQuery);
                }

                string strDeleteQuery = "Delete from SalesTemp where ID=" + Convert.ToInt16(str);
                objQueryController.ExecuteQuery(strDeleteQuery);

                string strGridQuery = "Select * from SalesTemp";
                DataTable dt = new DataTable();
                dt = objQueryController.ExecuteQuery(strGridQuery);

                grdSalesException.DataSource = dt;
                grdSalesException.DataBind();

            }
        }
    }