protected void btnInsertNew_Click(object sender, EventArgs e)
    {
        ISession sess = NHibernateSessionManager.Instance.GetSession();
        IList lstwcon = sess.CreateCriteria(typeof(Warrantycondition))
                .Add(Expression.Eq("Partcode", txtPartcode.Text.Trim())).List();

        if (!(lstwcon.Count > 0))
        {
            Warrantycondition wcon = new Warrantycondition();
            if (txtPartcode.Text.Trim().Length < 6 || txtPartcode.Text.Trim().Length > 35)
            {
                ShowMessage(Resources.Message.WarrantyCondition_PartcodeLength, true);
                return;
            }
            else wcon.Partcode = txtPartcode.Text.Trim();
            wcon.Partnamevn = txtPartNameVN.Text.Trim();
            wcon.Partnameen = txtPartNameEN.Text.Trim();
            wcon.Motorcode = txtModel.Text.Trim();
            wcon.Warrantytime = long.Parse(checkNotEmptyDataNumberic(txtWarrantyMonth.Text.Trim()));
            wcon.Warrantylength = decimal.Parse(checkNotEmptyDataNumberic(txtKMWarranty.Text.Trim()));
            wcon.Labour = decimal.Parse(checkNotEmptyDataNumberic(txtWarrantyCost.Text.Trim()));
            wcon.Manpower = NumberFormatHelper.StrDoubleToStr(txtStandartHours.Text.Trim(), Thread.CurrentThread.CurrentCulture.Name, "en-US");
            wcon.Unitprice = decimal.Parse(checkNotEmptyDataNumberic(txtUnitPrice.Text.Trim()));
            ITransaction tx = sess.BeginTransaction();
            sess.SaveOrUpdate(wcon);
            tx.Commit();
            ShowMessage(Resources.Message.ActionSucessful, false);
            placeSearchControl.Visible = true;
            CallViewControl(-1);
        }
        else
        {
            ShowMessage(Resources.Message.Part_AddNewFailed, true);
        }
    }
 public PCVItem(Warrantycondition spare)
     : this()
 {
     this.Partcodem = this.Partcodeo = spare.Partcode;
     this.PartName = (UserHelper.Language.Equals("vi-VN", StringComparison.OrdinalIgnoreCase)) ? spare.Partnamevn : spare.Partnameen;
     this.Unitpricem = this.Unitpriceo = (long)spare.Unitprice;
     this.Labour = spare.Labour;
     this.SManPower = spare.Manpower;
 }
 protected void gvSelectSpare_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
 {
     GridViewRow gvr = ((GridView)sender).Rows[e.NewSelectedIndex]; if (gvr == null) return;
     Literal lit = (Literal)WebTools.FindControlById("litSelectedSpareNumber", gvr);
     if (lit != null) selWarranty = WarrantyContent.GetWarrantyCondition(lit.Text);
     MultiView1.ActiveViewIndex = 0;
     ViewState[SELECTING_SPARE_KEY] = "false";
     ObjectDataSource1.SelectParameters["spareNumberLike"] = new Parameter("spareNumberLike", TypeCode.String, "");
     // trick on me
     EmptyGridViewEx1._debugGridOnObject = false;
 }
    protected void btnFindSpare_Click(object sender, EventArgs e)
    {
        string spareNum;

        TextBox tb = (TextBox)WebTools.FindControlById("txtSpareNumberM", EmptyGridViewEx1); if ((tb == null) && (sender != null)) return;

        spareNum = (tb != null) ? tb.Text : hdPartCode.Value;

        ObjectDataSource1.SelectParameters["spareNumberLike"] = new Parameter("spareNumberLike", TypeCode.String, spareNum);
        gvSelectSpare.PageIndex = 0;
        gvSelectSpare.DataBind();

        if (gvSelectSpare.Rows.Count == 1)
        {

            GridViewRow gvr = gvSelectSpare.Rows[0]; if (gvr == null) return;
            Literal lit = (Literal)WebTools.FindControlById("litSelectedSpareNumber", gvr);
            if (lit != null) selWarranty = WarrantyContent.GetWarrantyCondition(lit.Text);
            ObjectDataSource1.SelectParameters["spareNumberLike"] = new Parameter("spareNumberLike", TypeCode.String, "");
        }
        else if (gvSelectSpare.Rows.Count > 1)
        {
            MultiView1.ActiveViewIndex = 1;
            // trick on me
            EmptyGridViewEx1._debugGridOnObject = true;
            ViewState[SELECTING_SPARE_KEY] = "true";
        }
        else
        {
            MultiView1.ActiveViewIndex = 0;
            AddError(VerifyExchangeErrorCode.SpareNumberNotFound);
        }
    }
 // select spare
 protected void gvSelectSpare_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
 {
     GridViewRow gvr = ((GridView)sender).Rows[e.NewSelectedIndex]; if (gvr == null) return;
     Literal lit = (Literal)WebTools.FindControlById("litSelectedSpareNumber", gvr);
     if (lit != null) footWarranty = WarrantyContent.GetWarrantyCondition(lit.Text);
     if (_addExchange) SetAvtiveView(vwAddExchangeIndex); else SetAvtiveView(vwMainIndex);
     if (_addExchange) AddExchange1.AddSpareTofoot(footWarranty);
 }
    protected void btnFindSpare_Click(object sender, EventArgs e)
    {
        string spareNum;
        if (_addExchange)
        {
            spareNum = AddExchange1.GetLookingSpareNumber();
        }
        else
        {
            TextBox tb = (TextBox)WebTools.FindControlById("txtSpareNumber", gvSpareList); if (tb == null) return;
            spareNum = tb.Text;
        }

        ObjectDataSource1.SelectParameters["spareNumberLike"] = new Parameter("spareNumberLike", TypeCode.String, spareNum);
        gvSelectSpare.PageIndex = 0;
        gvSelectSpare.DataBind();

        if (gvSelectSpare.Rows.Count == 1)
        {

            GridViewRow gvr = gvSelectSpare.Rows[0]; if (gvr == null) return;
            Literal lit = (Literal)WebTools.FindControlById("litSelectedSpareNumber", gvr);
            if (lit != null) footWarranty = WarrantyContent.GetWarrantyCondition(lit.Text);
            if (_addExchange) AddExchange1.AddSpareTofoot(footWarranty);
        }
        else if (gvSelectSpare.Rows.Count > 1) SetAvtiveView(vwSelectSpareIndex);
        else
        {
            if (_addExchange) SetAvtiveView(vwAddExchangeIndex); else SetAvtiveView(vwMainIndex);
            AddError(WarrantyContentErrorCode.SpareNumberNotFound);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        errorCode.Clear();
        bllErrorMsg.Items.Clear();

        if (!IsPostBack)
        {
            btnHistory.OnClientClick = "window.open('repairhistory.aspx?engnum=','repairhis',''); return false;";
            btnList.OnClientClick = "window.open('repairlist.aspx','repairlist',''); return false;";
            //ddlBranchCode.DataTextField = "BranchName";
            ddlBranchCode.DataTextField = "BranchCode";
            ddlBranchCode.DataValueField = "BranchCode";
            //ddlBranchCode.Items.Insert(0, new ListItem("", ""));

            ddlDealer.DataTextField = "BranchCode";
            ddlDealer.DataValueField = "BranchCode";
            ddlDealer.DataSource = Dealer.GetListDealerByDatabase(UserHelper.DatabaseCode);

            ddlDealer.DataBind();
            GetBranchs();

            txtBuyDate.Text = DateTime.Now.ToShortDateString();
            txtRepairDate.Text = DateTime.Now.ToShortDateString();
            SetAvtiveView(vwMainIndex);
            gvSpareList.DataSourceTable = WarrantyContent.SpareListOnServiceSchema;
            gvSpareList.EmptyTableRowText = Message.WarrantyContent_EmptySpareList;
            gvSelectCust.EmptyDataText = Message.DataNotFound;

            gvSpareList.Columns[7].Visible = showFeeAmountColumn;
            ShowSumary = false;
            _finish = false;
            _saved = false;
            _saveTemp = false;
            _exchSaved = false;
            _addExchange = false;
            _canChangeBuyDate = false;

            gvSelectItem.PageSize = selectGridViewPageSize;
            gvSelectSpare.PageSize = selectSparePageSize;
            gvSelectModel.PageSize = selectGridViewPageSize;
            gvSelectBroken.PageSize = selectBrokenCodePageSize;
            gvSelectCust.PageSize = selectGridViewPageSize;

            ClearForm();

            // add new customer /////////////////
            string js = "if(retrieve_lookup_data('" + txtCustId.ClientID + "','../vehicle/sale/CusInfInput2.aspx?')==false) return false;";
            btnNewCus.OnClientClick = js;
            btnNewCus.UseSubmitBehavior = false;

            /////////////////////////////////////
            // SRS id to be edit
            string srsId = Request.QueryString["sid"];
            long.TryParse(srsId, out _editSheetId);

            // load temp SRS
            if (!string.IsNullOrEmpty(srsId))
            {
                ShowServiceSheet(false, _editSheetId);
            }

            // check km count for dealer
            CompareValidator1.ValidationGroup = (!UserHelper.IsDealer) ? "None" : "Save";
        }
        else
        {
            // bind data for frint form
            if (MultiView1.ActiveViewIndex == vwPrintIndex) btnPrint_Click(null, null);

            // keep tracking PVC
            if ((AddExchange1.ExchangeHeader == null) && (_exchangeHeader != null))
            {
                AddExchange1.ExchangeHeader = _exchangeHeader;
            }
        }

        _repairSpare = "";
        if (AddExchange1.OnFindSpareClick == null) AddExchange1.OnFindSpareClick += btnFindSpare_Click;
        if (AddExchange1.OnFindBrokenClick == null) AddExchange1.OnFindBrokenClick += btnFindBroken_Click;
        if (AddExchange1.OnCancelSaveListClick == null) AddExchange1.OnCancelSaveListClick += btnCancel_Click;
        if (AddExchange1.OnSaveListClick == null) AddExchange1.OnSaveListClick += btnSaveExchange_Click;
        if (AddExchange1.AddNewError == null) AddExchange1.AddNewError += AddError;

        // check and store sparenumber
        TextBox tb = (TextBox)WebTools.FindControlById("txtSpareNumber", gvSpareList);
        if (tb != null) _repairSpare = tb.Text;

        // check and store fee
        if (showFeeAmountColumn)
            _feeAmount = gvSpareList.SumBy("FeeAmount").ToString();
        else
        {
            tb = (TextBox)WebTools.FindControlById("txtFee", gvSpareList);
            if (tb != null)
            {
                if ((tb.Text.Trim() != _feeAmount) && (!string.IsNullOrEmpty(tb.Text))) _feeAmount = tb.Text.Trim();
                else if (string.IsNullOrEmpty(_feeAmount)) _feeAmount = "0";
                //if (string.IsNullOrEmpty(tb.Text)) tb.Text = _feeAmount;
            }
        }

        //CheckFinish();
        footWarranty = null;

        // show data from other page's query
        showServiceSheetNumber = Request.QueryString["srsn"];
        showExchangeSparesNumber = Request.QueryString["pcvn"];
        if (!string.IsNullOrEmpty(showServiceSheetNumber)) ShowServiceSheet(true, showServiceSheetNumber);
        else if (!string.IsNullOrEmpty(showExchangeSparesNumber)) ShowExchangeVoucher();

        //print Mes4lang
        LoadCustomerErr = Resources.Message.LoadCustomerErr;
    }
 private void ClearFootState()
 {
     footBroken = null; if (ViewState["Exchange_BrokenCode"] != null) ViewState.Remove("Exchange_BrokenCode");
     footWarr = null; if (ViewState["Exchange_SpareNumber"] != null) ViewState.Remove("Exchange_SpareNumber");
     quantity = "1";
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        errors.Clear();

        if (!IsPostBack)
        {
            if (sender != null) InitForm(); // manual call to pageLoad
            if (gvexSpareList.DataSourceTable == null)
                gvexSpareList.DataSourceTable = AddExchange.SpareListOnServiceSchema;

            gvexSpareList.EmptyTableRowText = Message.WarrantyContent_EmptySpareList;

            if (RawSpareList != null) gvexSpareList.DataSourceTable = RawSpareList;
        }
        if (ViewState["Exchange_BrokenCode"] != null)
        {
            brokenCode = ViewState["Exchange_BrokenCode"].ToString();
            footBroken = WarrantyContent.GetBroken(brokenCode);
        }
        if (ViewState["Exchange_SpareNumber"] != null)
        {
            spareNumber = ViewState["Exchange_SpareNumber"].ToString();
            footWarr = WarrantyContent.GetWarrantyCondition(spareNumber);
        }

        // save new spare quantity
        if (gvexSpareList.EditIndex < 0)
        {
            TextBox tb = (TextBox)WebTools.FindControlById("txtexQuantity", gvexSpareList);
            if (tb != null) quantity = tb.Text;
        }
    }
 public void AddSpareTofoot(Warrantycondition spare)
 {
     footWarr = spare;
     spareNumber = (spare != null) ? spare.Partcode : "";
     ViewState["Exchange_SpareNumber"] = spareNumber;
 }
Example #11
0
 public static string GetPartName(Warrantycondition warr)
 {
     return (Thread.CurrentThread.CurrentCulture.Name == "vi-VN") ? warr.Partnamevn : warr.Partnameen;
 }
 public SRSItem(Warrantycondition spare)
     : this()
 {
     this.Partcode = spare.Partcode;
     this.Partname = (UserHelper.Language.Equals("vi-VN", StringComparison.OrdinalIgnoreCase)) ? spare.Partnamevn : spare.Partnameen;
     this.Unitprice = (long)spare.Unitprice;
 }
        public SRSItem UpdateSRSItem(Warrantycondition warr, int quantity, decimal newUnitPrice)
        {
            SRSItem item = this.FindServiceItem(warr.Partcode);
            if ((item == null) && (quantity > 0))   // chua co thi add
            {
                item = new SRSItem(warr);
                item.State = ServiceItemState.Transient;
                item.Serviceheader = this.ServiceHeader;
                this.ServiceDetail.Add(item);
            }

            if (quantity > 0)  // co => update
            {
                item.HasModified = true;
                item.Partqty = quantity;
                item.Unitprice = (long)newUnitPrice;
            }
            else    // co nhung quantity==0 => remove
            {
                this.ServiceDetail.Remove(item);
                item = null;
            }

            return item;
        }
        public PCVItem UpdatePCVItem(Warrantycondition warr, int quantity)
        {
            PCVItem item = this.FindExchangeItem(warr.Partcode);
            if (item == null)   // chua co thi add
            {
                item = new PCVItem(warr);
                item.State = ServiceItemState.Transient;
                item.Partqtyo = quantity;
                item.Exchangepartheader = this.ExchangePartHeader;
                this.ExchangePartDetail.Add(item);
            }
            else if (quantity > 0)  // co => update
            {
                item.HasModified = true;
                item.Partqtyo = quantity;
                item.Unitpriceo = (long)warr.Unitprice;
            }
            else    // co nhung quantity==0 => remove
            {
                this.ExchangePartDetail.Remove(item);
                item = null;
            }

            return item;
        }