protected void Page_Load(object sender, EventArgs e)
        {
            int supplier_id;
            if (int.TryParse(Request.QueryString["id"], out supplier_id))
            {
                supplier_id = Convert.ToInt16(Request.QueryString["id"].ToString());
                if (supplier_id < 1)
                {
                    Response.Redirect("~/StoreClerk/SupplierList.aspx");
                }

                if (!Page.IsPostBack)
                {
                    SupplierController supplierController = new SupplierController();
                    Supplier supplier = supplierController.actionGetSuppierByID(supplier_id);

                    ui_id_hiddenfield.Value = supplier.id.ToString();
                    ui_code_textbox.Text = supplier.code;
                    ui_name_textbox.Text = supplier.supplier_name;
                    ui_contactname_textbox.Text = supplier.contact_name;
                    ui_phonenumber_textbox.Text = supplier.phone_number;
                    ui_faxnumber_textbox.Text = supplier.fax_number;
                    ui_email_textbox.Text = supplier.email;
                    ui_address_textbox.Text = supplier.address;

                    ui_content_title_label.Text = supplier.supplier_name;
                }
            }
            else
            {

            }
        }
        protected void ui_save_button_Click(object sender, EventArgs e)
        {
            SupplierController supplierController = new SupplierController();

            Supplier supplier = new Supplier();
            int supplier_id;

            //getting hidden field id
            if (int.TryParse(ui_id_hiddenfield.Value, out supplier_id))
            {
                supplier.id = Convert.ToInt32(ui_id_hiddenfield.Value);
            }

            //fields validation
            if (String.IsNullOrEmpty(ui_name_textbox.Text) || String.IsNullOrEmpty(ui_code_textbox.Text))
            {
                Response.Cookies.Add(new HttpCookie("flash_message", "Field(s) marked with * can't be empty.") { Path = "/" });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" });
                return;
                //String idstring = (supplier.id > 0) ? ("?id="+supplier.id) : ("");
                //Response.Redirect("~/StoreClerk/SupplierDetail.aspx"+idstring);
            }

            //setting up object
            supplier.code = ui_code_textbox.Text;
            supplier.supplier_name = ui_name_textbox.Text;
            supplier.contact_name = ui_contactname_textbox.Text;
            supplier.phone_number = ui_phonenumber_textbox.Text;
            supplier.fax_number = ui_faxnumber_textbox.Text;
            supplier.email = ui_email_textbox.Text;
            supplier.address = ui_address_textbox.Text;

            //updating db;
            Message message;
            if (supplier.id > 0)
            {
                message = supplierController.actionUpdateSupplier(supplier);
            }
            else {
                message = supplierController.actionCreateSupplier(supplier);
            }

            //redirecting
            if (message.condition)
            {
                Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Saved.") { Path = "/" });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" });
                Response.Redirect("~/StoreClerk/SupplierDetail.aspx?id=" + supplier.id);
            }
            else {
                Response.Cookies.Add(new HttpCookie("flash_message", message.message) { Path = "/" });
                Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" });
                Response.Redirect("~/StoreClerk/SupplierDetail.aspx?id=" + supplier.id);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SupplierController supplierController = new SupplierController();

            if (!Page.IsPostBack)
            {
                ui_supplier_gridview.DataSource = supplierController.actionGetSuppliers();
                ui_supplier_gridview.GridLines = GridLines.None;
                ui_supplier_gridview.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            User suser = (User)Session["user"];
            if (suser == null || suser.user_type != 4)
            {
                Response.Redirect("~/Login.aspx");
            }

            SupplierController suppliercontroller = new SupplierController();
            StationeryController stationerycontroller = new StationeryController();

            if(int.TryParse(Request.QueryString["id"],out stationery_id))
            {
                stationery_id = Convert.ToInt16(Request.QueryString["id"].ToString());
                if (stationery_id < 1)
                {
                    Response.Redirect("~/StoreClerk/InventoryStatus.aspx");
                }
                if (!Page.IsPostBack)
                {
                    User user = (User)Session["user"];
                    Stationery stationery = stationerycontroller.actionGetStationeryByID(stationery_id);
                    //Supplier supplier = suppliercontroller.actionGetSuppierByID(Convert.ToInt32(stationery.first_supplier));
                    ui_from_textbox.Text = user.email;

                    ui_to_dropdown.DataSource = stationerycontroller.actionGetStationeryViews();

                    ui_to_dropdown.DataSource = stationerycontroller.actionGetSuppliersOfAStationery(stationery.id);
                    ui_to_dropdown.DataTextField = "supplier_name";
                    ui_to_dropdown.DataValueField = "id";
                    ui_to_dropdown.DataBind();

                    ui_subject_textbox.Text = "Purchase Order from Logic University.";
                    ui_message_textbox.Text = "<p>Hello" + "" + ",</p>" +
                                              "<p>I would like to order the following item for our store. Please kindly proceed.</p>" +
                                              "<p><b>Stationery Name : "+stationery.stationery_name+"<br />"+
                                              "Quantity : " + stationery.reorder_quantity + "</b></p>" +
                                              "<p>Thank you,<br /> "+
                                              user.firstname + " " + user.lastname + " "+
                                              "(Logic University)</p>";

                    //+ stationery.stationery_name + stationery.category.ToString() + stationery.reorder_quantity.ToString()+""+"Regards, Logic University";

                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ui_content_title_label.Text = "Stock Card";
            Session["data:stock_card:stationery_id"] = null;
            StationeryController stationeryController = new StationeryController();
            SupplierController supplierController = new SupplierController();

            int stationery_id;
            if (int.TryParse(Request.QueryString["id"], out stationery_id))
            {
                stationery_id = Convert.ToInt16(Request.QueryString["id"].ToString());
                Session["data:stock_card:stationery_id"] = stationery_id;
                if (!(stationery_id > 0))
                {

                }

                if (!Page.IsPostBack)
                {

                    Stationery stationery = stationeryController.actionGetStationeryByID(stationery_id);
                    ui_stationery_code_label.Text = stationery.code.ToString();
                    ui_stationery_name_label.Text = stationery.stationery_name.ToString();
                    ui_stationery_bin_label.Text = stationery.bin.ToString();
                    ui_stationery_uom_label.Text = stationery.unit_of_measure.ToString();
                    ui_stationery_supplier1_label.Text = supplierController.actionGetSuppierByID(Convert.ToInt16(stationery.first_supplier)).supplier_name.ToString();
                    ui_stationery_supplier2_label.Text = supplierController.actionGetSuppierByID(Convert.ToInt16(stationery.second_supplier)).supplier_name.ToString();
                    ui_stationery_supplier3_label.Text = supplierController.actionGetSuppierByID(Convert.ToInt16(stationery.third_supplier)).supplier_name.ToString();
                    ui_seationerysearch_box.Text = stationery.stationery_name.ToString();
                    StockTransactionController stockContorller = new StockTransactionController();

                    //ui_stockcard_gridview.DataSource = new StockTransactionController().actionGetStockTransactionByStationeryId(2);
                    //ui_stockcard_gridview.DataBind();

                }
                else
                {

                }
            }
            else {
                ui_stationeryinfo_panel.CssClass = "hide";
            }
        }
        protected void ui_send_button_Click(object sender, EventArgs e)
        {
            Supplier supplier = new SupplierController().actionGetSuppierByID(Convert.ToInt32(ui_to_dropdown.SelectedValue));
            new PurchaseOrderController().actionCreateNewReOrderWithDefaultValue(stationery_id, supplier.id);

            if (ui_sentmail.Checked) {
                Helper.sendMail(supplier.email, ui_from_textbox.Text, ui_subject_textbox.Text, ui_message_textbox.Text);
            }

            if (ui_sentsms.Checked) {
                Stationery stationery = new StationeryController().actionGetStationeryByID(stationery_id);
                SMSController sms = new SMSController();
                sms.sendSMS(supplier.phone_number, "Purchase Order\r\n Stationery : "+ stationery.stationery_name + "\r\n Quantity : "+ stationery.reorder_quantity);
            }

            //ui_from_textbox.Text = "";
            //ui_subject_textbox.Text = "";
            //ui_message_textbox.Text = "";
            Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Made Purchase Order.") { Path = "/" });
            Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" });
            Response.Redirect("~/StoreClerk/InventoryStatus.aspx");
        }
        public Message actionCreateNewReOrderWithDefaultValue(int stationery_id, int supplier_id)
        {
            Stationery stationery = new StationeryController().actionGetStationeryByID(stationery_id);
            Supplier supplier = new SupplierController().actionGetSuppierByID(supplier_id);

            PurchaseOrder order = new PurchaseOrder();
            order.po_stationery = stationery.id;
            order.po_quantity_in_hand = stationery.quantity_in_stock - stationery.pending_quantity_to_distribute;
            order.po_reorder_date = DateTime.Now;
            order.po_reorder_level = stationery.reorder_level;
            order.po_reordered_quantity = stationery.reorder_quantity;
            order.po_supplier = supplier.id;

            try
            {
                data.PurchaseOrders.AddObject(order);
                return this.getNewDefaultMessageForDBOperations(data.SaveChanges() == 1);
            }
            catch (Exception e)
            {
                return this.getNewDefaultMessageForException(e);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                StationeryController stationeryController = new StationeryController();

                List<Supplier> suppliers = new SupplierController().actionGetSuppliers();

                int stationery_id;

                if (int.TryParse(Request.QueryString["id"], out stationery_id))
                {
                    stationery_id = Convert.ToInt16(Request.QueryString["id"].ToString());
                    if (stationery_id < 1)
                    {
                        Response.Redirect("~/m/DepartmentEmplyoee/Stationeries.aspx");
                    }

                    if (!Page.IsPostBack)
                    {
                        Stationery stationery = stationeryController.actionGetStationeryByID(stationery_id);
                        StationeryCategory category = stationeryController.actionGetStationeryCategoryByID(stationery.category);
                        ui_stationery_name.Text = stationery.stationery_name;
                        ui_category.Text = category.category_name;
                        ui_id_hidden.Value = stationery.id.ToString();
                        ui_uom.Text = stationery.unit_of_measure;
                        ui_price.Text = stationery.price.ToString();
                        ui_total.Text = stationery.price.ToString();
                        ui_price_hidden_forjscalculation.Value = stationery.price.ToString();
                    }
                }
                else
                {

                }
            }
        }
Exemple #9
0
        public Message actionCreateNewReOrderWithDefaultValue(int stationery_id, int supplier_id)
        {
            Stationery stationery = new StationeryController().actionGetStationeryByID(stationery_id);
            Supplier   supplier   = new SupplierController().actionGetSuppierByID(supplier_id);

            PurchaseOrder order = new PurchaseOrder();

            order.po_stationery         = stationery.id;
            order.po_quantity_in_hand   = stationery.quantity_in_stock - stationery.pending_quantity_to_distribute;
            order.po_reorder_date       = DateTime.Now;
            order.po_reorder_level      = stationery.reorder_level;
            order.po_reordered_quantity = stationery.reorder_quantity;
            order.po_supplier           = supplier.id;

            try
            {
                data.PurchaseOrders.AddObject(order);
                return(this.getNewDefaultMessageForDBOperations(data.SaveChanges() == 1));
            }
            catch (Exception e)
            {
                return(this.getNewDefaultMessageForException(e));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            StationeryController stationeryController = new StationeryController();

            List<Supplier> suppliers = new SupplierController().actionGetSuppliers();

            int stationery_id;

            if (int.TryParse(Request.QueryString["id"], out stationery_id))
            {
                stationery_id = Convert.ToInt16(Request.QueryString["id"].ToString());
                if (stationery_id < 1)
                {
                    Response.Redirect("~/StoreClerk/StationeryList.aspx");
                }

                if (!Page.IsPostBack)
                {

                    Stationery stationery = stationeryController.actionGetStationeryByID(stationery_id);

                    ui_id_hiddenfield.Value = stationery.id.ToString();
                    ui_code_textbox.Text = stationery.code.ToString();
                    ui_name_textbox.Text = stationery.stationery_name;

                    ui_category_dropdown.DataSource = stationeryController.actionGetStationeryCategories();
                    ui_category_dropdown.DataTextField = "category_name";
                    ui_category_dropdown.DataValueField = "id";
                    ui_category_dropdown.DataBind();
                    ui_category_dropdown.SelectedValue = stationery.category.ToString();

                    ui_price_textbox.Text = stationery.price.ToString();
                    ui_reorderlevel_textbox.Text = stationery.reorder_level.ToString(); ;
                    ui_reorderquantity_textbox.Text = stationery.reorder_quantity.ToString();
                    ui_quantityinstock_label.Text = stationery.quantity_in_stock.ToString();
                    ui_pendingquantity_label.Text = stationery.pending_quantity_to_distribute.ToString();
                    ui_uom_textbox.Text = stationery.unit_of_measure.ToString();
                    ui_binnum_textbox.Text = stationery.bin.ToString();

                    ui_firstsupplier_dropdown.DataSource = suppliers;
                    ui_secondsupplier_dropdown.DataSource = suppliers;
                    ui_thirdsupplier_dropdown.DataSource = suppliers;
                    ui_firstsupplier_dropdown.DataTextField = "supplier_name";
                    ui_firstsupplier_dropdown.DataValueField = "id";
                    ui_secondsupplier_dropdown.DataTextField = "supplier_name";
                    ui_secondsupplier_dropdown.DataValueField = "id";
                    ui_thirdsupplier_dropdown.DataTextField = "supplier_name";
                    ui_thirdsupplier_dropdown.DataValueField = "id";

                    ui_firstsupplier_dropdown.DataBind();
                    ui_secondsupplier_dropdown.DataBind();
                    ui_thirdsupplier_dropdown.DataBind();
                    ui_firstsupplier_dropdown.SelectedValue = stationery.first_supplier.ToString();
                    ui_secondsupplier_dropdown.SelectedValue = stationery.second_supplier.ToString();
                    ui_thirdsupplier_dropdown.SelectedValue = stationery.third_supplier.ToString();

                    ui_content_title_label.Text = stationery.stationery_name.ToString();
                }
            }
            else
            {
                String tmp_s1 = ui_firstsupplier_dropdown.SelectedValue;
                String tmp_s2 = ui_secondsupplier_dropdown.SelectedValue;
                String tmp_s3 = ui_thirdsupplier_dropdown.SelectedValue;
                String tmp_cate = ui_category_dropdown.SelectedValue;

                ui_category_dropdown.DataSource = stationeryController.actionGetStationeryCategories();
                ui_category_dropdown.DataTextField = "category_name";
                ui_category_dropdown.DataValueField = "id";
                ui_category_dropdown.DataBind();

                ui_firstsupplier_dropdown.DataSource = suppliers;
                ui_secondsupplier_dropdown.DataSource = suppliers;
                ui_thirdsupplier_dropdown.DataSource = suppliers;
                ui_firstsupplier_dropdown.DataTextField = "supplier_name";
                ui_firstsupplier_dropdown.DataValueField = "id";
                ui_secondsupplier_dropdown.DataTextField = "supplier_name";
                ui_secondsupplier_dropdown.DataValueField = "id";
                ui_thirdsupplier_dropdown.DataTextField = "supplier_name";
                ui_thirdsupplier_dropdown.DataValueField = "id";

                ui_firstsupplier_dropdown.DataBind();
                ui_secondsupplier_dropdown.DataBind();
                ui_thirdsupplier_dropdown.DataBind();

                ui_category_dropdown.SelectedValue = tmp_cate;
                ui_firstsupplier_dropdown.SelectedValue = tmp_s1;
                ui_secondsupplier_dropdown.SelectedValue = tmp_s2;
                ui_thirdsupplier_dropdown.SelectedValue = tmp_s3;
            }
        }
        public List<Supplier> actionGetSuppliersByItem(String name)
        {
            SupplierController supController = new SupplierController();
            var y = from x in data.Stationeries
                    where x.stationery_name == name
                    select x;

            List<Supplier> myList = new List<Supplier>();
            foreach (Stationery a in y)
            {
                myList.Add(supController.actionGetSuppierByID(Convert.ToInt32(a.first_supplier)));
                myList.Add(supController.actionGetSuppierByID(Convert.ToInt32(a.second_supplier)));
                myList.Add(supController.actionGetSuppierByID(Convert.ToInt32(a.third_supplier)));

            }
            return myList;
        }